02d9c526e2
Original problem is that lowered ir closures doesn't meet inliner expectations
about captured variable position in inlining method.
E.g.: Call 'foo(valueParam) { capturedParam }' to
inline function 'foo' with declaration
inline fun foo(valueParam: Foo, inlineParamWithCaptured: Bar.() ->) ....
is reorganized through inlining to equivalent call foo(valueParam, capturedParam1, cp2 ...).
But lowered closure for lambda parameter has totally different parameters order:
fun loweredLambda$x(extensionReceiver, captured1, cp2..., valueParam1, vp2...)
So before inlining lowered closure should be transformed to
fun loweredLambda$x(extensionReceiver, valueParam1, vp2..., captured1, cp2..)
#KT-28547 Fixed
19 lines
354 B
Kotlin
Vendored
19 lines
354 B
Kotlin
Vendored
// FILE: 1.kt
|
|
package test
|
|
|
|
public inline fun <T> with2(receiver: T, body: T.() -> String) = receiver.body()
|
|
|
|
// FILE: 2.kt
|
|
import test.*
|
|
|
|
inline fun <T : Any> test(item: T?, defaultLink: T.() -> String): String {
|
|
return with2("") {
|
|
item?.defaultLink() ?: "fail"
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
return test("O") {
|
|
this + "K"
|
|
}
|
|
} |