Report special diagnostic when fake-call receiver is nullable

#KT-3602 Fixed
This commit is contained in:
Denis Zharkov
2016-02-01 13:49:49 +03:00
parent 829a5639f1
commit 816c66063b
14 changed files with 34 additions and 35 deletions
@@ -8,7 +8,7 @@ fun test() {
// Error
container<!UNSAFE_CALL!>.<!>iterator()
// for extension iterator, this code compiles, but should not
for (s in <!ITERATOR_MISSING!>container<!>) {}
for (s in <!ITERATOR_ON_NULLABLE!>container<!>) {}
}
class OtherContainer<K>(val k: K) {
operator fun iterator(): Iterator<K> = null!!
@@ -17,5 +17,5 @@ class OtherContainer<K>(val k: K) {
fun test2() {
val other: OtherContainer<String>? = null
// Error
for (s in <!ITERATOR_MISSING!>other<!>) {}
for (s in <!ITERATOR_ON_NULLABLE!>other<!>) {}
}
@@ -8,7 +8,7 @@ class It {
}
fun test(c: Coll?) {
for (x in <!ITERATOR_MISSING!>c<!>) {}
for (x in <!ITERATOR_ON_NULLABLE!>c<!>) {}
if (c != null) {
for(x in <!DEBUG_INFO_SMARTCAST!>c<!>) {}
@@ -7,7 +7,7 @@ operator fun <T> Data<T>.component2() = y
fun foo(): Int {
val d: Data<Int>? = null
// An error must be here
val (x, y) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>d<!>
val (x, y) = <!COMPONENT_FUNCTION_ON_NULLABLE, COMPONENT_FUNCTION_ON_NULLABLE!>d<!>
return x + y
}
@@ -16,6 +16,6 @@ data class NormalData<T>(val x: T, val y: T)
fun bar(): Int {
val d: NormalData<Int>? = null
// An error must be here
val (x, y) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>d<!>
val (x, y) = <!COMPONENT_FUNCTION_ON_NULLABLE, COMPONENT_FUNCTION_ON_NULLABLE!>d<!>
return <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>+<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>y<!>
}
@@ -22,7 +22,7 @@ fun test() {
val platformJ = J.staticJ
for (x in platformNN) {}
for (x in <!ITERATOR_MISSING!>platformN<!>) {}
for (x in <!ITERATOR_ON_NULLABLE!>platformN<!>) {}
for (x in platformJ) {}
}
@@ -27,6 +27,6 @@ fun test() {
val platformJ = J.staticJ
val (a1, b1) = platformNN
val (a2, b2) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>platformN<!>
val (a2, b2) = <!COMPONENT_FUNCTION_ON_NULLABLE, COMPONENT_FUNCTION_ON_NULLABLE!>platformN<!>
val (a3, b3) = platformJ
}