Add "'equals()' between objects of inconvertible types" inspection

#KT-25006 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-04-04 11:55:39 +03:00
committed by Mikhail Glukhikh
parent a1979677d0
commit a2205cfc98
29 changed files with 331 additions and 0 deletions
@@ -0,0 +1,3 @@
// PROBLEM: none
val x = 2.<caret>equals("")
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.KotlinEqualsBetweenInconvertibleTypesInspection
@@ -0,0 +1,8 @@
// PROBLEM: none
fun test(x: E1, y: E1): Boolean {
return x.<caret>equals(y)
}
enum class E1
@@ -0,0 +1,9 @@
// FIX: none
fun test(x: E1, y: E2): Boolean {
return x.<caret>equals(y)
}
enum class E1
enum class E2
@@ -0,0 +1,7 @@
// FIX: none
fun test(x: E1, y: Int): Boolean {
return x.<caret>equals(y)
}
enum class E1
@@ -0,0 +1,7 @@
// FIX: none
fun test(x: E1, y: String): Boolean {
return x.<caret>equals(y)
}
enum class E1
@@ -0,0 +1,9 @@
// PROBLEM: none
fun test(x: E1, y: Foo): Boolean {
return x.<caret>equals(y)
}
class Foo
enum class E1
@@ -0,0 +1,7 @@
// FIX: none
fun test(x: Int, y: E1): Boolean {
return x.<caret>equals(y)
}
enum class E1
@@ -0,0 +1,5 @@
// PROBLEM: none
fun test(x: Int, y: Int): Boolean {
return x.<caret>equals(y)
}
@@ -0,0 +1,5 @@
// FIX: none
fun test(x: Int, y: Long): Boolean {
return x.<caret>equals(y)
}
@@ -0,0 +1,5 @@
// FIX: none
fun test(x: Int, y: String): Boolean {
return x.<caret>equals(y)
}
@@ -0,0 +1,7 @@
// PROBLEM: none
fun test(x: Int, y: Foo): Boolean {
return x.<caret>equals(y)
}
class Foo
@@ -0,0 +1,6 @@
// FIX: none
enum class E1
fun test(x: E1?, y: String): Boolean? {
return x?.<caret>equals(y)
}
@@ -0,0 +1,4 @@
// FIX: none
fun test(x: Int?, y: String): Boolean? {
return x?.<caret>equals(y)
}
@@ -0,0 +1,4 @@
// FIX: none
fun test(x: String?, y: Int): Boolean? {
return x?.<caret>equals(y)
}
@@ -0,0 +1,4 @@
// PROBLEM: none
fun test() {
System.getProperty("some")?.<caret>equals("true")
}
@@ -0,0 +1,7 @@
// FIX: none
fun test(x: String, y: E1): Boolean {
return x.<caret>equals(y)
}
enum class E1
@@ -0,0 +1,5 @@
// FIX: none
fun test(x: String, y: Int): Boolean {
return x.<caret>equals(y)
}
@@ -0,0 +1,6 @@
// FIX: none
enum class E1
fun test(x: String, y: E1?): Boolean? {
return x.<caret>equals(y)
}
@@ -0,0 +1,4 @@
// FIX: none
fun test(x: String, y: Int?): Boolean? {
return x.<caret>equals(y)
}
@@ -0,0 +1,4 @@
// PROBLEM: none
fun test(x: String, y: String?): Boolean? {
return x.<caret>equals(y)
}
@@ -0,0 +1,5 @@
// PROBLEM: none
fun test(x: String, y: String): Boolean {
return x.<caret>equals(y)
}
@@ -0,0 +1,7 @@
// PROBLEM: none
fun test(x: String, y: Foo): Boolean {
return x.<caret>equals(y)
}
class Foo
@@ -0,0 +1,7 @@
// PROBLEM: none
fun test(x: Foo, y: Int): Boolean {
return x.<caret>equals(y)
}
class Foo