Prefer stable types to diagnose useless cast
#KT-11622 Fixed
This commit is contained in:
+2
-2
@@ -8,11 +8,11 @@ fun test() : Unit {
|
||||
checkSubtype<Int>(y)
|
||||
checkSubtype<Int>(x as Int)
|
||||
checkSubtype<Int>(y <!USELESS_CAST!>as Int<!>)
|
||||
checkSubtype<Int?>(x <!USELESS_CAST!>as Int?<!>)
|
||||
checkSubtype<Int?>(x as Int?)
|
||||
checkSubtype<Int?>(y as Int?)
|
||||
checkSubtype<Int?>(x <!USELESS_CAST!>as? Int<!>)
|
||||
checkSubtype<Int?>(y <!USELESS_CAST!>as? Int<!>)
|
||||
checkSubtype<Int?>(x <!USELESS_CAST!>as? Int?<!>)
|
||||
checkSubtype<Int?>(x as? Int?)
|
||||
checkSubtype<Int?>(y as? Int?)
|
||||
|
||||
val <!UNUSED_VARIABLE!>s<!> = "" as Any
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface I1
|
||||
interface I2
|
||||
|
||||
fun foo(i: I1) {}
|
||||
fun foo(i: I2) {}
|
||||
|
||||
fun bar(i: I1) {
|
||||
if (i is I2) {
|
||||
foo(i as I1)
|
||||
foo(i as I2)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ i: I1): kotlin.Unit
|
||||
public fun foo(/*0*/ i: I1): kotlin.Unit
|
||||
public fun foo(/*0*/ i: I2): kotlin.Unit
|
||||
|
||||
public interface I1 {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface I2 {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user