FIR checker: warn useless as and is
This commit is contained in:
committed by
TeamCityServer
parent
19d939c36e
commit
e2dc21da90
@@ -1,20 +0,0 @@
|
||||
open class C {
|
||||
}
|
||||
|
||||
fun C.foo() {}
|
||||
|
||||
open class X {
|
||||
companion object : C() {}
|
||||
}
|
||||
|
||||
open class Y {
|
||||
companion object : C() {}
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
val x = X
|
||||
x.foo()
|
||||
X.foo()
|
||||
(X as C).foo()
|
||||
((if (1<2) X else Y) as C).foo()
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
open class C {
|
||||
}
|
||||
|
||||
|
||||
+11
-1
@@ -33,8 +33,18 @@ inline fun <reified T> case_5() {
|
||||
|
||||
val z = x.test()
|
||||
|
||||
if (z is T) {
|
||||
if (<!USELESS_IS_CHECK!>z is T<!>) {
|
||||
// z is {T!! & T!!} (smart cast from T)
|
||||
<!UNRESOLVED_REFERENCE!>println<!>(z)
|
||||
}
|
||||
|
||||
val a = object<A> {
|
||||
fun test() = 42 as <!UNRESOLVED_REFERENCE!>A<!>
|
||||
}
|
||||
|
||||
val b = a.test()
|
||||
|
||||
if (a is T) {
|
||||
<!UNRESOLVED_REFERENCE!>println<!>(a)
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -37,4 +37,14 @@ inline fun <reified T> case_5() {
|
||||
// z is {T!! & T!!} (smart cast from T)
|
||||
<!UNRESOLVED_REFERENCE!>println<!>(z)
|
||||
}
|
||||
|
||||
val a = object<!TYPE_PARAMETERS_IN_ANONYMOUS_OBJECT!><A><!> {
|
||||
fun test() = 42 <!UNCHECKED_CAST!>as A<!>
|
||||
}
|
||||
|
||||
val b = a.test()
|
||||
|
||||
if (a is T) {
|
||||
<!UNRESOLVED_REFERENCE!>println<!>(a)
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+11
-1
@@ -33,8 +33,18 @@ inline fun <reified T> case_5() {
|
||||
|
||||
val z = x.test()
|
||||
|
||||
if (z is T) {
|
||||
if (<!USELESS_IS_CHECK!>z is T<!>) {
|
||||
// z is {T!! & T!!} (smart cast from T)
|
||||
<!UNRESOLVED_REFERENCE!>println<!>(z)
|
||||
}
|
||||
|
||||
val a = object<A> {
|
||||
fun test() = 42 as <!UNRESOLVED_REFERENCE!>A<!>
|
||||
}
|
||||
|
||||
val b = a.test()
|
||||
|
||||
if (a is T) {
|
||||
<!UNRESOLVED_REFERENCE!>println<!>(a)
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -37,4 +37,14 @@ inline fun <reified T> case_5() {
|
||||
// z is {T!! & T!!} (smart cast from T)
|
||||
<!UNRESOLVED_REFERENCE!>println<!>(z)
|
||||
}
|
||||
|
||||
val a = object<!TYPE_PARAMETERS_IN_OBJECT!><A><!> {
|
||||
fun test() = 42 <!UNCHECKED_CAST!>as A<!>
|
||||
}
|
||||
|
||||
val b = a.test()
|
||||
|
||||
if (a is T) {
|
||||
<!UNRESOLVED_REFERENCE!>println<!>(a)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user