KT-1199 - test and fix for erased case

This commit is contained in:
Alex Tkachman
2012-02-11 11:09:02 +02:00
parent a9e1eb3615
commit 8d9434548f
3 changed files with 25 additions and 1 deletions
@@ -0,0 +1,20 @@
fun <erased T : Any> T?.iterator() = object {
var hasNext = this@iterator != null
private set
fun next() : T {
if (hasNext) {
hasNext = false
return this@iterator.sure()
}
throw java.util.NoSuchElementException()
}
}
fun box() : String {
var k = 0
for (i in 1) {
k++
}
return if(k == 1) "OK" else "fail"
}