KT-3491 Wrong (or not obvious) warning
#KT-3491 Fixed
This commit is contained in:
@@ -4,6 +4,6 @@ fun foo() {
|
||||
val x: Int? = null
|
||||
|
||||
bar(x ?: 0)
|
||||
if (x != null) bar(x ?: x)
|
||||
if (x != null) bar(<!USELESS_ELVIS!>x<!> ?: x)
|
||||
bar(<!TYPE_MISMATCH!>x<!>)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// For KT-3491
|
||||
|
||||
fun <T: Any?> test1(t: Any?): Any {
|
||||
return t as T ?: ""
|
||||
}
|
||||
|
||||
fun <T: Any> test2(t: Any?): Any {
|
||||
return <!USELESS_ELVIS!>t as T<!> ?: ""
|
||||
}
|
||||
|
||||
fun <T: Any?> test3(t: Any?): Any {
|
||||
if (t != null) {
|
||||
return <!USELESS_ELVIS!>t<!> ?: ""
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
Reference in New Issue
Block a user