FIR checker: warn useless as and is

This commit is contained in:
Jinseong Jeon
2021-04-28 22:32:51 -07:00
committed by TeamCityServer
parent 19d939c36e
commit e2dc21da90
141 changed files with 417 additions and 543 deletions
+1 -1
View File
@@ -13,6 +13,6 @@ interface B
fun test_2(x: Any?) {
if (x is A && x is B) {
x is A
<!USELESS_IS_CHECK!>x is A<!>
}
}
@@ -27,7 +27,7 @@ fun test_1(e: A) {
val d = when (e) {
is E -> 1
is A -> 2
<!USELESS_IS_CHECK!>is A<!> -> 2
}.plus(0)
}
@@ -1,6 +1,6 @@
fun foo() = if (true) 1 else 0
fun bar(arg: Any?) = when (arg) {
is Int -> arg as Int
is Int -> arg <!USELESS_CAST!>as Int<!>
else -> 42
}
@@ -3,7 +3,7 @@ class Some
fun foo(): () -> Boolean {
val s = Some()
if (true) {
return { if (s is Some) true else false }
return { if (<!USELESS_IS_CHECK!>s is Some<!>) true else false }
} else {
return { true }
}
@@ -14,7 +14,7 @@ class Case1() {
this.yield("") //UNRESOLVED_REFERENCE
this as SequenceScope<String>
this <!USELESS_CAST!>as SequenceScope<String><!>
yield("") // resolved to SequenceScope.yield
@@ -31,10 +31,10 @@ fun case2() {
this.yield("") //UNRESOLVED_REFERENCE
this as SequenceScope<String>
this <!USELESS_CAST!>as SequenceScope<String><!>
yield("") // UNRESOLVED_REFERENCE
this.yield("") // UNRESOLVED_REFERENCE
}
}
}