Files
kotlin-fork/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionNext.kt
T
Alexander Korepanov 6bb939c6cb [FIR JS] Support JS_NAME_CLASH and JS_FAKE_NAME_CLASH diagnostics
^KT-59425 Fixed
^KT-59370 Fixed
2023-09-08 09:55:25 +00:00

32 lines
542 B
Kotlin
Vendored

// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6, WASM
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
class It {
var hasNext = true
operator fun hasNext() = if (hasNext) {hasNext = false; true} else false
}
class C {
operator fun iterator(): It = It()
}
class X {
operator fun It.next() = 5
fun test() {
for (i in C()) {
foo(i)
}
}
}
fun foo(x: Int) {}
fun box(): String {
X().test()
return "OK"
}