Files
kotlin/compiler/testData/codegen/box/constructorCall/nestedConstructorCallWithJumpOutInConstructorArguments.kt
Juan Chen 573188bdc4 [FIR2IR]: fix translation of this references in instance methods
Currently FirThisReceiverExpression of instance methods are translated
to references of the class' thisReceiver,
not the method's dispatch receiver,
which causes problems with IrFrameMap::typeOf,
as the class' thisReceiver is not in the typeMap.

This commit translates non-qualified "this" references of
instance methods to references of the methods' dispatch receiver.
2020-01-10 10:43:07 +03:00

36 lines
720 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: test.kt
fun box(): String {
for (count in 0..3) {
val test = Foo(count, Foo(1, "x", 2), if (count > 0) break else 3)
if (count > 0) return "Fail: count = $count"
if (test.toString() != "Foo(0,Foo(1,x,2),3)") return "Fail: ${test.toString()}"
}
return "OK"
}
// FILE: util.kt
val log = StringBuilder()
fun <T> logged(msg: String, value: T): T {
log.append(msg)
return value
}
// FILE: Foo.kt
class Foo(val a: Int, val b: Any, val c: Int) {
init {
log.append("<init>")
}
override fun toString() = "Foo($a,$b,$c)"
companion object {
init {
log.append("<clinit>")
}
}
}