KT-1478 Quick fix for using nullable collection in "for in" expression
#KT-1478 Fixed
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
fun <T: Collection<Int>?> foo(c: T) {
|
||||
for (i in <caret>c) { }
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
fun <T: Collection<Int>?> foo(c: T) {
|
||||
for (i in c!!) { }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
fun foo() {
|
||||
val test : Collection<Int>? = null!!
|
||||
for (i in <caret>test) { }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
fun foo() {
|
||||
val test : Collection<Int>? = null!!
|
||||
for (i in <caret>test!!) { }
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Add non-null asserted (!!) call" "false"
|
||||
// ACTION: Replace with a 'forEach' function call
|
||||
// ERROR: For-loop range must have an iterator() method
|
||||
|
||||
class Some {
|
||||
fun iterator(): Iterator<Int> = null!!
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val test: Some? = Some()
|
||||
for (i in <caret>test) { }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
class Some {
|
||||
operator fun iterator(): Iterator<Int> = null!!
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val test: Some? = Some()
|
||||
for (i in <caret>test) { }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
class Some {
|
||||
operator fun iterator(): Iterator<Int> = null!!
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val test: Some? = Some()
|
||||
for (i in test!!) { }
|
||||
}
|
||||
Reference in New Issue
Block a user