KT-8110 J2K: Don't convert "==" to "===" for enum classes
#KT-8110 Fixed
This commit is contained in:
@@ -137,6 +137,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
|
||||
is PsiClassType -> {
|
||||
val psiClass = type.resolve() ?: return false
|
||||
if (!psiClass.hasModifierProperty(PsiModifier.FINAL)) return false
|
||||
if (psiClass.isEnum()) return true
|
||||
|
||||
val equalsSignature = GenerateEqualsHelper.getEqualsSignature(converter.project, GlobalSearchScope.allScope(converter.project))
|
||||
val equalsMethod = MethodSignatureUtil.findMethodBySignature(psiClass, equalsSignature, true)
|
||||
|
||||
+6
-1
@@ -20,8 +20,12 @@ class B {
|
||||
|
||||
final class BB extends B {}
|
||||
|
||||
enum EE {
|
||||
A, B, C
|
||||
}
|
||||
|
||||
class X {
|
||||
void foo(I i1, I i2, String s1, String s2, C c1, C c2, int i, O o1, O o2, E e1, E e2, BB bb1, BB bb2, int[] arr1, int[] arr2) {
|
||||
void foo(I i1, I i2, String s1, String s2, C c1, C c2, int i, O o1, O o2, E e1, E e2, BB bb1, BB bb2, int[] arr1, int[] arr2, EE ee1, EE ee2) {
|
||||
if (i1 == i2) return;
|
||||
if (s1 == s2) return;
|
||||
if (c1 == c2) return;
|
||||
@@ -32,6 +36,7 @@ class X {
|
||||
if (e1 == e2) return;
|
||||
if (bb1 == bb2) return;
|
||||
if (arr1 == arr2) return;
|
||||
if (ee1 == ee2 || ee1 == null) return;
|
||||
|
||||
if (s1 != s2) return;
|
||||
if (c1 != c2) return;
|
||||
|
||||
+6
-1
@@ -18,8 +18,12 @@ open class B {
|
||||
|
||||
class BB : B()
|
||||
|
||||
enum class EE {
|
||||
A, B, C
|
||||
}
|
||||
|
||||
class X {
|
||||
fun foo(i1: I?, i2: I?, s1: String, s2: String, c1: C, c2: C, i: Int, o1: O, o2: O, e1: E, e2: E, bb1: BB, bb2: BB, arr1: IntArray, arr2: IntArray) {
|
||||
fun foo(i1: I?, i2: I?, s1: String, s2: String, c1: C, c2: C, i: Int, o1: O, o2: O, e1: E, e2: E, bb1: BB, bb2: BB, arr1: IntArray, arr2: IntArray, ee1: EE?, ee2: EE) {
|
||||
if (i1 === i2) return
|
||||
if (s1 === s2) return
|
||||
if (c1 == c2) return
|
||||
@@ -30,6 +34,7 @@ class X {
|
||||
if (e1 === e2) return
|
||||
if (bb1 === bb2) return
|
||||
if (arr1 == arr2) return
|
||||
if (ee1 == ee2 || ee1 == null) return
|
||||
|
||||
if (s1 !== s2) return
|
||||
if (c1 != c2) return
|
||||
|
||||
Reference in New Issue
Block a user