Files
kotlin-fork/compiler/testData/ir/irText/expressions/posptonedPCLACallInsideStringInterpolation.kt
Denis.Zharkov 66d8f471d9 K2: Fix internal error in FIR2IR caused by PCLA + String interpolation
There's an implicit contract in PCLA that the statement-level call
should be postponed iff it has something to be postponed inside.

And that contract didn't work well for string interpolation containing
some postponed calls.

Thus, we haven't run a completion results writing for them properly,
thus leaving type parameters (K from synthetic call) for expression
types instead of an inferred substituted type.

In this commit, the contract was reversed to explicitly enumerate
the cases when it's safe to resolve the candidate outside PCLA session.

See the comments at `mightBeAnalyzedAndCompletedIndependently`.

^KT-65341 Fixed
2024-02-02 15:40:47 +00:00

24 lines
560 B
Kotlin
Vendored

// FIR_IDENTICAL
// ISSUE: KT-65341
class Controller<K> {
fun yield(k: K) {}
}
fun <T> generate(lambda: Controller<T>.() -> Unit) {}
fun <E> id(e: E): E = e
// Regular function irrelevant to PCLA
fun bar(s: String) {}
fun foo() {
generate {
// `bar(..)` itself is a regular function that should not be postponed
// But its argument is a string interpolation that contains a postponed call `id(this)`
// And by our current rule, the whole call needs to be postponed, too
bar("${id(this)}")
yield("")
}
}