Introduce FirForLoopChecker
This commit is contained in:
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// See also KT-7428
|
||||
class Container<K>(val k: K)
|
||||
// iterator() must be an extension, otherwise code will not compile
|
||||
operator fun <K> Container<K>.iterator(): Iterator<K> = null!!
|
||||
|
||||
fun test() {
|
||||
val container: Container<String>? = null
|
||||
// Error
|
||||
container<!UNSAFE_CALL!>.<!>iterator()
|
||||
// for extension iterator, this code compiles, but should not
|
||||
<!UNSAFE_CALL!>for (s in container) {}<!>
|
||||
}
|
||||
class OtherContainer<K>(val k: K) {
|
||||
operator fun iterator(): Iterator<K> = null!!
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
val other: OtherContainer<String>? = null
|
||||
// Error
|
||||
<!UNSAFE_CALL!>for (s in other) {}<!>
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !WITH_NEW_INFERENCE
|
||||
// See also KT-7428
|
||||
class Container<K>(val k: K)
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
|
||||
fun foo1() = <!EXPRESSION_EXPECTED!>while (b()) {}<!>
|
||||
|
||||
fun foo2() = <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>for (i in 10) {}<!>
|
||||
fun foo2() = for (i in <!ITERATOR_MISSING!>10<!>) {}
|
||||
|
||||
fun foo3() = when (b()) {
|
||||
true -> 1
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ class It {
|
||||
}
|
||||
|
||||
fun test(c: Coll?) {
|
||||
<!UNSAFE_CALL!>for (x in c) {}<!>
|
||||
for (x in <!ITERATOR_ON_NULLABLE!>c<!>) {}
|
||||
|
||||
if (c != null) {
|
||||
for(x in c) {}
|
||||
|
||||
+1
-1
@@ -8,5 +8,5 @@ class It {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
<!UNSAFE_CALL, UNSAFE_CALL!>for (x in Coll()) {}<!>
|
||||
for (x in <!HAS_NEXT_FUNCTION_NONE_APPLICABLE!>Coll()<!>) {}
|
||||
}
|
||||
Reference in New Issue
Block a user