Add inspection to detect is checks for object types #KT-21741 Fixed

This commit is contained in:
Toshiaki Kameyama
2017-12-18 12:14:34 +03:00
committed by Mikhail Glukhikh
parent 247881baf9
commit 84a6ef6ac4
15 changed files with 228 additions and 0 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.RedundantObjectTypeCheckInspection
@@ -0,0 +1,7 @@
// PROBLEM: none
class C
fun foo(arg: Any) {
if (arg <caret>is C) {
}
}
@@ -0,0 +1,9 @@
// PROBLEM: none
class C
fun foo(arg: Any) {
when (arg) {
<caret>is C -> {
}
}
}
@@ -0,0 +1,6 @@
object O
fun foo(arg: Any) {
if (arg <caret>!is O) {
}
}
@@ -0,0 +1,6 @@
object O
fun foo(arg: Any) {
if (arg != O) {
}
}
@@ -0,0 +1,9 @@
// PROBLEM: none
object O
fun foo(arg: Any) {
when (arg) {
<caret>!is O -> {
}
}
}
@@ -0,0 +1,6 @@
object O
fun foo(arg: Any) {
if (arg <caret>is O) {
}
}
@@ -0,0 +1,6 @@
object O
fun foo(arg: Any) {
if (arg == O) {
}
}
@@ -0,0 +1,8 @@
object O
fun foo(arg: Any) {
when (arg) {
<caret>is O -> {
}
}
}
@@ -0,0 +1,8 @@
object O
fun foo(arg: Any) {
when (arg) {
O -> {
}
}
}