Properly check whether nullability of receiver argument fits to parameter's nullability
It's should behave like we check isSubtype(receiverType, parameterType) + use nullability info from smart cast #KT-1090 Fixed
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION,-UNUSED_VARIABLE
|
||||
|
||||
fun <T : CharSequence?> T.bar1() {}
|
||||
fun CharSequence?.bar2() {}
|
||||
|
||||
fun <T : CharSequence> T.bar3() {}
|
||||
fun CharSequence.bar4() {}
|
||||
|
||||
fun <T : String?> T.foo() {
|
||||
if (this != null) {
|
||||
if (<!SENSELESS_COMPARISON!>this != null<!>) {}
|
||||
|
||||
length()
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length()
|
||||
|
||||
bar1()
|
||||
bar2()
|
||||
<!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar3<!>()
|
||||
bar4()
|
||||
|
||||
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
|
||||
}
|
||||
|
||||
<!UNSAFE_CALL!>length<!>()
|
||||
|
||||
if (this is String) {
|
||||
length()
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length()
|
||||
|
||||
bar1()
|
||||
bar2()
|
||||
<!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar3<!>()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user