Files
kotlin/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclFor.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

35 lines
648 B
Kotlin
Vendored

class Range(val from : C, val to: C) {
operator fun iterator() = It(from, to)
}
class It(val from: C, val to: C) {
var c = from.i
operator fun next(): C {
val next = C(c)
c++
return next
}
operator fun hasNext(): Boolean = c <= to.i
}
class C(val i : Int) {
operator fun component1() = i + 1
operator fun component2() = i + 2
operator fun rangeTo(c: C) = Range(this, c)
}
fun doTest(): String {
var s = ""
for ((a, b) in C(0)..C(2)) {
s += "$a:$b;"
}
return s
}
fun box(): String {
val s = doTest()
return if (s == "1:2;2:3;3:4;") "OK" else "fail: $s"
}