Files
kotlin-fork/compiler/testData/codegen/box/safeCall/kt245.kt
T
Mark Punzalan 5afab1ac2b [FIR] FIR2IR: Populate calls with type arguments and function type
parameters with bounds/supertypes.
2019-11-25 09:37:47 +03:00

34 lines
704 B
Kotlin
Vendored

// KJS_WITH_FULL_RUNTIME
fun foo() {
val l = ArrayList<Int>(2)
l.add(1)
for (el in l) {}
//verify error "Expecting to find integer on stack"
val iterator = l.iterator()
//another verify error "Mismatched stack types"
while (iterator?.hasNext() ?: false) {
val i = iterator?.next()
}
//the same
if (iterator != null) {
while (iterator.hasNext()) {
val i = iterator?.next()
}
}
//this way it works
if (iterator != null) {
while (iterator.hasNext()) {
iterator.next() //because of the bug KT-244 i can't write "val i = iterator.next()"
}
}
}
fun box() : String {
return "OK"
}