[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
@@ -27,15 +27,15 @@ fun foo(l: A<String>?) {
|
||||
foo(l?.bar()) checkType { _<String?>() }
|
||||
foo(l?.gav()) checkType { _<String?>() }
|
||||
if (l != null) {
|
||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
||||
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()<!>) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
||||
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()<!>) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
||||
}
|
||||
}
|
||||
|
||||
fun fooNotNull(l: A<String>) {
|
||||
// No errors should be here
|
||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
||||
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()<!>) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
||||
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()<!>) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
|
||||
+4
-4
@@ -27,15 +27,15 @@ fun foo(l: A<String>?) {
|
||||
foo(l?.bar()) checkType { _<String?>() }
|
||||
foo(l?.gav()) checkType { _<String?>() }
|
||||
if (l != null) {
|
||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()) checkType { _<String>() }
|
||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()) checkType { _<String>() }
|
||||
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()<!>) checkType { _<String>() }
|
||||
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()<!>) checkType { _<String>() }
|
||||
}
|
||||
}
|
||||
|
||||
fun fooNotNull(l: A<String>) {
|
||||
// No errors should be here
|
||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()) checkType { _<String>() }
|
||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()) checkType { _<String>() }
|
||||
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()<!>) checkType { _<String>() }
|
||||
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()<!>) checkType { _<String>() }
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
|
||||
@@ -12,7 +12,7 @@ fun <T : CharSequence?> foo(x: T) {
|
||||
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
|
||||
|
||||
x.length
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
x.bar1()
|
||||
x.bar2()
|
||||
@@ -20,14 +20,14 @@ fun <T : CharSequence?> foo(x: T) {
|
||||
x.bar4()
|
||||
|
||||
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()<!>
|
||||
}
|
||||
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
|
||||
if (x is String) {
|
||||
x.length
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
x.bar1()
|
||||
x.bar2()
|
||||
@@ -36,7 +36,7 @@ fun <T : CharSequence?> foo(x: T) {
|
||||
|
||||
if (x is CharSequence) {
|
||||
x.length
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
x.bar1()
|
||||
x.bar2()
|
||||
|
||||
@@ -12,7 +12,7 @@ fun <T : CharSequence?> foo(x: T) {
|
||||
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
|
||||
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
|
||||
x.bar2()
|
||||
@@ -20,14 +20,14 @@ fun <T : CharSequence?> foo(x: T) {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.bar4()
|
||||
|
||||
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()<!>
|
||||
}
|
||||
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
|
||||
if (x is String) {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
|
||||
x.bar2()
|
||||
@@ -36,7 +36,7 @@ fun <T : CharSequence?> foo(x: T) {
|
||||
|
||||
if (x is CharSequence) {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
|
||||
x.bar2()
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ fun <T : String?> T.foo() {
|
||||
if (<!SENSELESS_COMPARISON!>this != null<!>) {}
|
||||
|
||||
length
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
bar1()
|
||||
bar2()
|
||||
@@ -19,14 +19,14 @@ fun <T : String?> T.foo() {
|
||||
bar4()
|
||||
|
||||
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()<!>
|
||||
}
|
||||
|
||||
<!UNSAFE_CALL!>length<!>
|
||||
|
||||
if (this is String) {
|
||||
length
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
bar1()
|
||||
bar2()
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ fun <T : String?> T.foo() {
|
||||
if (<!SENSELESS_COMPARISON!>this != null<!>) {}
|
||||
|
||||
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>length<!>
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>bar1<!>()
|
||||
bar2()
|
||||
@@ -19,14 +19,14 @@ fun <T : String?> T.foo() {
|
||||
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>bar4<!>()
|
||||
|
||||
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()<!>
|
||||
}
|
||||
|
||||
<!UNSAFE_CALL!>length<!>
|
||||
|
||||
if (this is String) {
|
||||
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>length<!>
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||
|
||||
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>bar1<!>()
|
||||
bar2()
|
||||
|
||||
Reference in New Issue
Block a user