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
40 lines
565 B
Kotlin
Vendored
40 lines
565 B
Kotlin
Vendored
// FILE: 1.kt
|
|
|
|
package test
|
|
|
|
inline fun linearLayout2(init: X.() -> Unit) {
|
|
return X().init()
|
|
}
|
|
|
|
var result = "fail"
|
|
class X {
|
|
fun calc() {
|
|
result = "OK"
|
|
}
|
|
}
|
|
|
|
// FILE: 2.kt
|
|
//NO_CHECK_LAMBDA_INLINING
|
|
import test.*
|
|
|
|
class A {
|
|
fun test() {
|
|
linearLayout2 {
|
|
{
|
|
apply2 {
|
|
this@linearLayout2::calc
|
|
}()
|
|
}()
|
|
}
|
|
}
|
|
|
|
public fun <T, Z> T.apply2(block: T.() -> Z): Z {
|
|
return block()
|
|
}
|
|
|
|
}
|
|
|
|
fun box(): String {
|
|
A().test()
|
|
return result
|
|
} |