"Replace 'if' with elvis operator": don't suggest on super type check

#KT-27016 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-09-26 13:18:45 +03:00
committed by Mikhail Glukhikh
parent ffa3d7c57a
commit fd6f34f8ca
7 changed files with 95 additions and 0 deletions
@@ -0,0 +1,13 @@
open class A
open class B : A() {
fun b() {}
}
fun test() {
val b = B()
if (<caret>b !is B) {
return
}
b.b()
}
@@ -0,0 +1,10 @@
open class A
open class B : A() {
fun b() {}
}
fun test() {
val b = B() as? B ?: return
b.b()
}
@@ -0,0 +1,17 @@
open class A
open class B : A() {
fun b() {}
}
open class C : B() {
fun c() {}
}
fun test() {
val b = B()
if (<caret>b !is C) {
return
}
b.b()
}
@@ -0,0 +1,14 @@
open class A
open class B : A() {
fun b() {}
}
open class C : B() {
fun c() {}
}
fun test() {
val b = B() as? C ?: return
b.b()
}
@@ -0,0 +1,14 @@
// IS_APPLICABLE: false
open class A
open class B : A() {
fun b() {}
}
fun test() {
val b = B()
if (<caret>b !is A) {
return
}
b.b()
}