Files
kotlin/compiler/testData/codegen/controlStructures/forLoopMemberExtensionNext.kt
Andrey Breslav e57e61ac68 For-loop generation rewritten for the case of explicit iterator usage
This implementation includes multi-declarations already, but tests are coming in the next commits.
Old ForLoopgenerator renamed to IntrinsicForLoopGenerator, and will be unified with the newly introduced interface soon.

Side-effect:
KT-2668 Codegen doesn't handle member extensions in for
 #KT-2668 Fixed
2012-08-24 19:49:31 +04:00

23 lines
325 B
Kotlin

class It {
var hasNext = true
fun hasNext() = if (hasNext) {hasNext = false; true} else false
}
class C {
fun iterator(): It = It()
}
class X {
fun It.next() = 5
fun test() {
for (i in C()) {
System.out.println(i)
}
}
}
fun main(args: Array<String>) {
X().test()
}