Files
kotlin-fork/compiler/testData/codegen/box/jvmStatic/convention.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

36 lines
425 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_RUNTIME
class B(var s: Int = 0) {
}
object A {
fun test1(v: B) {
v += B(1000)
}
@JvmStatic operator fun B.plusAssign(b: B) {
this.s += b.s
}
}
fun box(): String {
val b1 = B(11)
with(A) {
b1 += B(1000)
}
if (b1.s != 1011) return "fail 1"
val b = B(11)
A.test1(b)
if (b.s != 1011) return "fail 2"
return "OK"
}