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
This commit is contained in:
Andrey Breslav
2012-08-23 19:09:31 +04:00
parent 4870b92d11
commit e57e61ac68
5 changed files with 288 additions and 83 deletions
@@ -0,0 +1,23 @@
class It {
fun next() = 5
}
class C {
fun iterator(): It = It()
}
class X {
var hasNext = true
fun It.hasNext() = if (hasNext) {hasNext = false; true} else false
fun test() {
for (i in C()) {
System.out.println(i)
}
}
}
fun main(args: Array<String>) {
X().test()
}