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
39 lines
603 B
Kotlin
Vendored
39 lines
603 B
Kotlin
Vendored
// FILE: 1.kt
|
|
// WITH_RUNTIME
|
|
package test
|
|
|
|
public class Data(val value: Int)
|
|
|
|
public class Input(val d: Data) {
|
|
public fun data() : Int = 100
|
|
}
|
|
|
|
public inline fun <R> use(block: ()-> R) : R {
|
|
return block()
|
|
}
|
|
|
|
// FILE: 2.kt
|
|
|
|
//NO_CHECK_LAMBDA_INLINING
|
|
import test.*
|
|
|
|
fun test1(d: Data): Int {
|
|
val input = Input(d)
|
|
var result = 10
|
|
with(input) {
|
|
fun localFun() {
|
|
result = input.d.value
|
|
}
|
|
localFun()
|
|
}
|
|
return result
|
|
}
|
|
|
|
|
|
fun box(): String {
|
|
val result = test1(Data(11))
|
|
if (result != 11) return "test1: ${result}"
|
|
|
|
return "OK"
|
|
}
|