Files
kotlin-fork/compiler/testData/codegen/box/lazyCodegen/ifElse.kt
T
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

34 lines
646 B
Kotlin
Vendored

class A (val p: String, p1: String, p2: String) {
var cond1 :String = ""
var cond2 :String = ""
val prop: String = if (p == "test") p1 else p2
val prop1 = if (cond1(p)) p1 else false
val prop2 = if (cond2(p)) true else false
fun cond1(p: String): Boolean {
cond1 = "cond1"
return p == "test"
}
fun cond2(p: String): Boolean {
cond2 = "cond2"
return p == "test"
}
}
fun box(): String {
val a = A("test", "OK", "fail")
if (a.prop != "OK") return "fail 1"
if (a.cond1 != "cond1") return "fail 2"
if (a.cond2 != "cond2") return "fail 3"
return "OK"
}