Files
kotlin-fork/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/sideEffects.kt
T
Mikhael Bogdanov 02d9c526e2 Proper resort variables on inlining lowered ir closures
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
2019-01-03 07:57:36 +01:00

20 lines
384 B
Kotlin
Vendored

// WITH_RUNTIME
class Foo {
lateinit var bar: String
fun test(): String {
var state = 0
if (run { state++; this }::bar.isInitialized) return "Fail 1"
bar = "A"
if (!run { state++; this }::bar.isInitialized) return "Fail 3"
return if (state == 2) "OK" else "Fail: state=$state"
}
}
fun box(): String {
return Foo().test()
}