fix for KT-241

This commit is contained in:
Alex Tkachman
2011-09-03 12:02:42 +02:00
parent 555ebebe1b
commit 672756e459
9 changed files with 127 additions and 30 deletions
@@ -0,0 +1,45 @@
fun box() : String {
val c5 = MyCollection3()
for (el in c5) {}
val c1: java.lang.Iterable<Int> = MyCollection1()
for (el in c1) {}
val c2 = MyCollection1()
for (el in c2) {}
/*
val c3: Iterable<Int> = MyCollection2()
for (el in c3) {}
val c4 = MyCollection2()
for (el in c4) {}
*/
return "OK"
}
class MyCollection1(): java.lang.Iterable<Int> {
fun iterator(): java.util.Iterator<Int> = MyIterator()
class MyIterator(): java.util.Iterator<Int> {
fun next() = 0
fun hasNext() = false
}
}
class MyCollection2(): Iterable<Int> {
fun iterator(): Iterator<Int> = MyIterator()
class MyIterator(): Iterator<Int> {
fun next() = 0
fun hasNext() = false
}
}
class MyCollection3() {
fun iterator() = MyIterator()
class MyIterator() {
fun next() = 0
fun hasNext() = false
}
}
@@ -39,6 +39,11 @@ fun t3 () : Boolean {
if(d.isT(10)) return false
if(!d.isT(null)) return false
val f = B<java.lang.String?>()
if(!f.isT("aaa")) return false
if(f.isT(10)) return false
if(!f.isT(null)) return false
val c = B<Int>()
if(c.isT("aaa")) return false
if(!c.isT(10)) return false