[FE] Add clear warning about future changes about nullability of safe call with non nullable receiver
^KT-46860
This commit is contained in:
committed by
teamcityserver
parent
937f4c1dab
commit
f26059a7d3
+2
-2
@@ -58,7 +58,7 @@ public class A {
|
||||
// FILE: main.kt
|
||||
fun main(a: A) {
|
||||
a.foo("").length
|
||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
a.bar("")<!UNSAFE_CALL!>.<!>length
|
||||
a.bar(null)?.length
|
||||
@@ -73,5 +73,5 @@ fun main(a: A) {
|
||||
|
||||
a.baz3()<!UNSAFE_CALL!>.<!>get(0).length
|
||||
a.baz3()!!.get(0).length
|
||||
a.baz3()!!.get(0)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.baz3()!!.get(0)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
}
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ public class A {
|
||||
// FILE: main.kt
|
||||
fun main(a: A) {
|
||||
a.foo("").length
|
||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
a.bar("")<!UNSAFE_CALL!>.<!>length
|
||||
a.bar(null)?.length
|
||||
|
||||
compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jsr305/springNullableWithTypeUse.kt
Vendored
+3
-3
@@ -63,17 +63,17 @@ public class A {
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a: A) {
|
||||
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
a.foo("", null).length
|
||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||
|
||||
a.bar().length
|
||||
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
|
||||
|
||||
a.field<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.field<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
a.field.length
|
||||
|
||||
a.baz()<!UNSAFE_CALL!>.<!>get(0)
|
||||
a.baz()!!.get(0).get(0)
|
||||
a.baz()!!.get(0)<!UNNECESSARY_SAFE_CALL!>?.<!>get(0)
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.baz()!!.get(0)<!UNNECESSARY_SAFE_CALL!>?.<!>get(0)<!>
|
||||
}
|
||||
|
||||
+2
-2
@@ -58,10 +58,10 @@ public class A {
|
||||
// FILE: main.kt
|
||||
fun main(a: A) {
|
||||
a.foo("").length
|
||||
a.foo(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
a.bar("").length
|
||||
a.bar(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.bar(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
a.baz1().get(0).length
|
||||
a.baz1()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.get(0).length
|
||||
|
||||
Vendored
+2
-2
@@ -58,7 +58,7 @@ public class A {
|
||||
// FILE: main.kt
|
||||
fun main(a: A) {
|
||||
a.foo("").length
|
||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
a.bar("")<!UNSAFE_CALL!>.<!>length
|
||||
a.bar(null)?.length
|
||||
@@ -73,5 +73,5 @@ fun main(a: A) {
|
||||
|
||||
a.baz3()<!UNSAFE_CALL!>.<!>get(0).length
|
||||
a.baz3()!!.get(0).length
|
||||
a.baz3()!!.get(0)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.baz3()!!.get(0)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
}
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ fun safeCalls() {
|
||||
val a = jsr.string?.length
|
||||
val b = jsrNullable?.string?.length
|
||||
|
||||
val c = jb.string<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
val c = <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>jb.string<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
val d = jbNullable?.string?.length
|
||||
|
||||
val e = platform.string?.length
|
||||
|
||||
Vendored
+1
-1
@@ -64,7 +64,7 @@ fun safeCalls() {
|
||||
val a = jsr.string<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
val b = jsrNullable?.string?.length
|
||||
|
||||
val c = jb.string<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
val c = <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>jb.string<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
val d = jbNullable?.string?.length
|
||||
|
||||
val e = platform.string?.length
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ fun main(a: A) {
|
||||
a.field.length
|
||||
a.field = null
|
||||
|
||||
a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
a.nonNullField.length
|
||||
a.nonNullField = <!NULL_FOR_NONNULL_TYPE!>null<!>
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ fun main(a: A) {
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.field<!>.length
|
||||
a.field = null
|
||||
|
||||
a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
a.nonNullField.length
|
||||
a.nonNullField = <!NULL_FOR_NONNULL_TYPE!>null<!>
|
||||
}
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ fun main(a: A) {
|
||||
a.field<!UNSAFE_CALL!>.<!>length
|
||||
a.field = null
|
||||
|
||||
a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
a.nonNullField.length
|
||||
a.nonNullField = <!NULL_FOR_NONNULL_TYPE!>null<!>
|
||||
}
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ public class A {
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a: A) {
|
||||
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
a.foo("", null).length
|
||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ fun main(a: A, b: B, c: C) {
|
||||
c.foo2(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
|
||||
c.foo3(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
|
||||
c.bar1(null).length
|
||||
c.bar1(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>c.bar1(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
c.bar2(null)<!UNSAFE_CALL!>.<!>length
|
||||
c.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
|
||||
}
|
||||
|
||||
+4
-4
@@ -127,7 +127,7 @@ public class A {
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a: A, b: A.B, c: A.C) {
|
||||
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
a.foo("", null).length
|
||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||
|
||||
@@ -137,7 +137,7 @@ fun main(a: A, b: A.B, c: A.C) {
|
||||
a.bar().length
|
||||
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
|
||||
|
||||
a.field<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.field<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
a.field.length
|
||||
|
||||
a.baz()<!UNSAFE_CALL!>.<!>get(0)
|
||||
@@ -150,7 +150,7 @@ fun main(a: A, b: A.B, c: A.C) {
|
||||
b.foo(null, "")<!UNSAFE_CALL!>.<!>length
|
||||
|
||||
b.foobar(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||
b.foobar("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>b.foobar("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
b.bar()<!UNSAFE_CALL!>.<!>length
|
||||
b.bar()!!.length
|
||||
@@ -163,7 +163,7 @@ fun main(a: A, b: A.B, c: A.C) {
|
||||
b.baz()!!.get(0)?.get(0)
|
||||
|
||||
// c
|
||||
c.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>c.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
c.foo("", null).length
|
||||
c.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class A {
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a: A) {
|
||||
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
a.foo("", null).length
|
||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class A {
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a: test.A) {
|
||||
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
a.foo("", null).length
|
||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||
|
||||
|
||||
+2
-2
@@ -15,6 +15,6 @@ public class A {
|
||||
// FILE: main.kt
|
||||
fun main(a: A) {
|
||||
a.foo("").length
|
||||
a.foo("")<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo("")<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user