Fix the case of safe call and elvis operators: flexible types may be nullable
This commit is contained in:
+2
-2
@@ -1,11 +1,11 @@
|
||||
fun <T> test(t: T): String {
|
||||
fun <T> test(t: T): String? {
|
||||
if (t != null) {
|
||||
return t<!UNNECESSARY_SAFE_CALL!>?.<!>toString()
|
||||
}
|
||||
return t?.toString()
|
||||
}
|
||||
|
||||
fun <T> T.testThis(): String {
|
||||
fun <T> T.testThis(): String? {
|
||||
if (this != null) {
|
||||
return this<!UNNECESSARY_SAFE_CALL!>?.<!>toString()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// FILE: p/J.java
|
||||
|
||||
package p;
|
||||
|
||||
public class J {
|
||||
public String s() { return null; }
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
import p.*
|
||||
|
||||
fun test(j: J) {
|
||||
j.s()?.length ?: ""
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// !CHECK_TYPE
|
||||
// FILE: p/J.java
|
||||
|
||||
package p;
|
||||
|
||||
public class J {
|
||||
public String s() { return null; }
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
import p.*
|
||||
|
||||
fun test(j: J) {
|
||||
j.s()?.length.checkType { it : _<Int?> }
|
||||
}
|
||||
Reference in New Issue
Block a user