KT-6118 Redundant type cast can be not redundant?
#KT-6118 Fixed
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
fun test(a: Any?) {
|
||||
if (a == null) return
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.hashCode()
|
||||
|
||||
val b = a
|
||||
<!DEBUG_INFO_SMARTCAST!>b<!>.hashCode()
|
||||
|
||||
val c: Any? = a
|
||||
c<!UNSAFE_CALL!>.<!>hashCode()
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
internal fun test(/*0*/ a: kotlin.Any?): kotlin.Unit
|
||||
@@ -0,0 +1,16 @@
|
||||
// KT-6118 Redundant type cast can be not redundant?
|
||||
|
||||
fun foo(o: Any) {
|
||||
if (o is String) {
|
||||
val s = o <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as String<!>
|
||||
s.length()
|
||||
}
|
||||
}
|
||||
|
||||
fun foo1(o: Any) {
|
||||
if (o is String) {
|
||||
<!DEBUG_INFO_SMARTCAST!>o<!>.length()
|
||||
val s = o
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
internal fun foo(/*0*/ o: kotlin.Any): kotlin.Unit
|
||||
internal fun foo1(/*0*/ o: kotlin.Any): kotlin.Unit
|
||||
@@ -0,0 +1,15 @@
|
||||
fun test(a: Any?, flag: Boolean, x: Any?) {
|
||||
if (a !is String) return
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.length()
|
||||
|
||||
val b: Any?
|
||||
|
||||
if (flag) {
|
||||
b = a
|
||||
<!DEBUG_INFO_SMARTCAST!>b<!>.length()
|
||||
}
|
||||
else {
|
||||
b = x
|
||||
b.<!UNRESOLVED_REFERENCE!>length<!>()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
internal fun test(/*0*/ a: kotlin.Any?, /*1*/ flag: kotlin.Boolean, /*2*/ x: kotlin.Any?): kotlin.Unit
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fun test(a: Any?, flag: Boolean, x: Any?) {
|
||||
if (a == null) return
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.hashCode()
|
||||
|
||||
val b: Any?
|
||||
|
||||
if (flag) {
|
||||
b = a
|
||||
<!DEBUG_INFO_SMARTCAST!>b<!>.hashCode()
|
||||
}
|
||||
else {
|
||||
b = x
|
||||
b<!UNSAFE_CALL!>.<!>hashCode()
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
internal fun test(/*0*/ a: kotlin.Any?, /*1*/ flag: kotlin.Boolean, /*2*/ x: kotlin.Any?): kotlin.Unit
|
||||
@@ -0,0 +1,12 @@
|
||||
fun test(a: Any?) {
|
||||
when (a) {
|
||||
is String -> {
|
||||
val s = a
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
}
|
||||
"" -> {
|
||||
val s = a
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.hashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
internal fun test(/*0*/ a: kotlin.Any?): kotlin.Unit
|
||||
Reference in New Issue
Block a user