[FIR] Fix K2 behavior according to RULES1
The compiler should only report diagnostics for
comparisons over builtins and identity-less types,
other incompatibilities should be reported
via inspections.
It's ok that in `equalityChecksOnIntegerTypes`
instead of `EQUALITY_NOT_APPLICABLE_WARNING` we get
`EQUALITY_NOT_APPLICABLE`, because
`ProperEqualityChecksInBuilderInferenceCalls`
is already active by default.
This change also replaces the notion of a representative superclass
with the least upper bound.
This makes complex types like
intersection/flexible transparent to
RULES1-based compatibility checks.
One way to look at it is to think
that this is an automatic way of handling
type parameters: automatic picking of
"interesting" bounds, and checking them against one another.
Note that `TypeIntersector.intersectTypes`
for `Int` and `T` where `T` is a type parameter
may return both `{Int & T}` or `null`
depending on `T`-s bounds. At the same time,
for type parameters `T` and `K` it will
always return `{T & K}`.
`ConeTypeIntersector.intersectTypes`, on the
other hand, will always return `{Int & T}`
irrespectively of the bounds. Meaning, the two
intersectors differ in corner cases.
`lowerBoundIfFlexible` call in `isLiterallyTypeParameter` is backed by
the `equalityOfFlexibleTypeParameters` test.
^KT-35134 #fixed-in-k2
^KT-22499 #fixed-in-k2
^KT-46383 #fixed-in-k2
This commit is contained in:
committed by
Space Team
parent
06e687addd
commit
f0720c1d12
@@ -1,17 +0,0 @@
|
||||
// !LANGUAGE: -ProhibitComparisonOfIncompatibleEnums
|
||||
// FILE: JavaEnumA.java
|
||||
|
||||
public enum JavaEnumA {}
|
||||
|
||||
// FILE: JavaEnumB.java
|
||||
|
||||
public enum JavaEnumB {}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
enum class KotlinEnumA
|
||||
enum class KotlinEnumB
|
||||
|
||||
fun jj(a: JavaEnumA, b: JavaEnumB) = <!EQUALITY_NOT_APPLICABLE_WARNING!>a == b<!>
|
||||
fun jk(a: JavaEnumA, b: KotlinEnumB) = <!EQUALITY_NOT_APPLICABLE_WARNING!>a == b<!>
|
||||
fun kk(a: KotlinEnumA, b: KotlinEnumB) = <!EQUALITY_NOT_APPLICABLE_WARNING!>a == b<!>
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: -ProhibitComparisonOfIncompatibleEnums
|
||||
// FILE: JavaEnumA.java
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
interface Buffered {
|
||||
fun flush()
|
||||
}
|
||||
|
||||
interface AIPowered {
|
||||
fun getAvatarReleaseYear(): Int
|
||||
}
|
||||
|
||||
enum class BufferedEnum : Buffered {
|
||||
A, B;
|
||||
override fun flush() {}
|
||||
}
|
||||
|
||||
enum class UsualEnum {
|
||||
C, D;
|
||||
}
|
||||
|
||||
enum class CleverEnum : Buffered, AIPowered {
|
||||
E, F;
|
||||
override fun flush() {}
|
||||
override fun getAvatarReleaseYear() = 2022
|
||||
}
|
||||
|
||||
fun <P> processInfo1(info: String, printer: P) where P: Buffered, P: AIPowered {
|
||||
<!EQUALITY_NOT_APPLICABLE!>printer == 20<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>printer == BufferedEnum.A<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>printer == UsualEnum.C<!>
|
||||
printer == CleverEnum.E
|
||||
}
|
||||
|
||||
fun <P> processInfo2(info: String, printer: P) where P: AIPowered, P: Buffered {
|
||||
<!EQUALITY_NOT_APPLICABLE!>printer == 20<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>printer == BufferedEnum.A<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>printer == UsualEnum.C<!>
|
||||
printer == CleverEnum.E
|
||||
}
|
||||
|
||||
abstract class Printer {
|
||||
abstract fun print(command: String)
|
||||
}
|
||||
|
||||
fun <P> processInfo3(info: String, printer: P) where P: Buffered, P: Printer {
|
||||
<!EQUALITY_NOT_APPLICABLE!>printer == 20<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>printer == BufferedEnum.A<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>printer == UsualEnum.C<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>printer == CleverEnum.E<!>
|
||||
}
|
||||
|
||||
fun test(a: Int, b: Any?) {
|
||||
<!IMPLICIT_BOXING_IN_IDENTITY_EQUALS!>a === b<!>
|
||||
}
|
||||
|
||||
fun <<!CONFLICTING_UPPER_BOUNDS, INCONSISTENT_TYPE_PARAMETER_BOUNDS, MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T: <!FINAL_UPPER_BOUND!>Int<!><!>> rest(a: T, b: Any?) where T : <!FINAL_UPPER_BOUND, ONLY_ONE_CLASS_BOUND_ALLOWED!>String<!> {
|
||||
<!IMPLICIT_BOXING_IN_IDENTITY_EQUALS!>a === b<!>
|
||||
}
|
||||
|
||||
fun <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T: Any?<!>> nest(a: Int, b: T) where T : <!FINAL_UPPER_BOUND, ONLY_ONE_CLASS_BOUND_ALLOWED!>String<!> {
|
||||
<!FORBIDDEN_IDENTITY_EQUALS!>a === b<!>
|
||||
}
|
||||
|
||||
fun <<!CONFLICTING_UPPER_BOUNDS, INCONSISTENT_TYPE_PARAMETER_BOUNDS, MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T: <!FINAL_UPPER_BOUND!>Int<!><!>, <!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>K: Any?<!>> mest(a: T, b: K) where T : <!FINAL_UPPER_BOUND, ONLY_ONE_CLASS_BOUND_ALLOWED!>String<!>, K: <!FINAL_UPPER_BOUND, ONLY_ONE_CLASS_BOUND_ALLOWED!>Boolean<!> {
|
||||
<!FORBIDDEN_IDENTITY_EQUALS_WARNING!>a === b<!>
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
interface Buffered {
|
||||
fun flush()
|
||||
}
|
||||
|
||||
interface AIPowered {
|
||||
fun getAvatarReleaseYear(): Int
|
||||
}
|
||||
|
||||
enum class BufferedEnum : Buffered {
|
||||
A, B;
|
||||
override fun flush() {}
|
||||
}
|
||||
|
||||
enum class UsualEnum {
|
||||
C, D;
|
||||
}
|
||||
|
||||
enum class CleverEnum : Buffered, AIPowered {
|
||||
E, F;
|
||||
override fun flush() {}
|
||||
override fun getAvatarReleaseYear() = 2022
|
||||
}
|
||||
|
||||
fun <P> processInfo1(info: String, printer: P) where P: Buffered, P: AIPowered {
|
||||
<!EQUALITY_NOT_APPLICABLE!>printer == 20<!>
|
||||
printer == BufferedEnum.A
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>printer == UsualEnum.C<!>
|
||||
printer == CleverEnum.E
|
||||
}
|
||||
|
||||
fun <P> processInfo2(info: String, printer: P) where P: AIPowered, P: Buffered {
|
||||
<!EQUALITY_NOT_APPLICABLE!>printer == 20<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>printer == BufferedEnum.A<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>printer == UsualEnum.C<!>
|
||||
printer == CleverEnum.E
|
||||
}
|
||||
|
||||
abstract class Printer {
|
||||
abstract fun print(command: String)
|
||||
}
|
||||
|
||||
fun <P> processInfo3(info: String, printer: P) where P: Buffered, P: Printer {
|
||||
<!EQUALITY_NOT_APPLICABLE!>printer == 20<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>printer == BufferedEnum.A<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>printer == UsualEnum.C<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>printer == CleverEnum.E<!>
|
||||
}
|
||||
|
||||
fun test(a: Int, b: Any?) {
|
||||
<!IMPLICIT_BOXING_IN_IDENTITY_EQUALS!>a === b<!>
|
||||
}
|
||||
|
||||
fun <<!INCONSISTENT_TYPE_PARAMETER_BOUNDS, MISPLACED_TYPE_PARAMETER_CONSTRAINTS!><!CONFLICTING_UPPER_BOUNDS!>T<!>: <!FINAL_UPPER_BOUND!>Int<!><!>> rest(a: T, b: Any?) where T : <!FINAL_UPPER_BOUND, ONLY_ONE_CLASS_BOUND_ALLOWED!>String<!> {
|
||||
a === b
|
||||
}
|
||||
|
||||
fun <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T: Any?<!>> nest(a: Int, b: T) where T : <!FINAL_UPPER_BOUND, ONLY_ONE_CLASS_BOUND_ALLOWED!>String<!> {
|
||||
<!EQUALITY_NOT_APPLICABLE!>a === b<!>
|
||||
}
|
||||
|
||||
fun <<!INCONSISTENT_TYPE_PARAMETER_BOUNDS, MISPLACED_TYPE_PARAMETER_CONSTRAINTS!><!CONFLICTING_UPPER_BOUNDS!>T<!>: <!FINAL_UPPER_BOUND!>Int<!><!>, <!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>K: Any?<!>> mest(a: T, b: K) where T : <!FINAL_UPPER_BOUND, ONLY_ONE_CLASS_BOUND_ALLOWED!>String<!>, K: <!FINAL_UPPER_BOUND, ONLY_ONE_CLASS_BOUND_ALLOWED!>Boolean<!> {
|
||||
a === b
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// FILE: A.java
|
||||
|
||||
class MyHelpers {
|
||||
public static <T> T id(T it) {
|
||||
return it;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: B.kt
|
||||
|
||||
fun <<!CONFLICTING_UPPER_BOUNDS, INCONSISTENT_TYPE_PARAMETER_BOUNDS, MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T: <!FINAL_UPPER_BOUND!>Int<!><!>, <!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>K: Any?<!>> mest(a: T, b: K) where T : <!FINAL_UPPER_BOUND, ONLY_ONE_CLASS_BOUND_ALLOWED!>String<!>, K: <!FINAL_UPPER_BOUND, ONLY_ONE_CLASS_BOUND_ALLOWED!>Boolean<!> {
|
||||
<!FORBIDDEN_IDENTITY_EQUALS_WARNING!>MyHelpers.id(a) === MyHelpers.id(b)<!>
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// FILE: A.java
|
||||
|
||||
class MyHelpers {
|
||||
public static <T> T id(T it) {
|
||||
return it;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: B.kt
|
||||
|
||||
fun <<!INCONSISTENT_TYPE_PARAMETER_BOUNDS, MISPLACED_TYPE_PARAMETER_CONSTRAINTS!><!CONFLICTING_UPPER_BOUNDS!>T<!>: <!FINAL_UPPER_BOUND!>Int<!><!>, <!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>K: Any?<!>> mest(a: T, b: K) where T : <!FINAL_UPPER_BOUND, ONLY_ONE_CLASS_BOUND_ALLOWED!>String<!>, K: <!FINAL_UPPER_BOUND, ONLY_ONE_CLASS_BOUND_ALLOWED!>Boolean<!> {
|
||||
MyHelpers.id(a) === MyHelpers.id(b)
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
// !LANGUAGE: -ProhibitComparisonOfIncompatibleEnums
|
||||
|
||||
interface I {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
enum class E1 : I {
|
||||
A {
|
||||
override fun foo() {
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>this == E2.A<!>
|
||||
|
||||
val q = this
|
||||
when (q) {
|
||||
this -> {}
|
||||
E1.A -> {}
|
||||
E1.B -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>E2.A<!> -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>E2.B<!> -> {}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
},
|
||||
B {
|
||||
override fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class E2 : I {
|
||||
A {
|
||||
override fun foo() {
|
||||
|
||||
}
|
||||
},
|
||||
B {
|
||||
override fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun foo1(e1: E1, e2: E2) {
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == e2<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 != e2<!>
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == E2.A<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>E1.B == e2<!>
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>E1.A == E2.B<!>
|
||||
|
||||
e1 == E1.A
|
||||
E1.A == e1
|
||||
e2 == E2.B
|
||||
E2.B == e2
|
||||
}
|
||||
|
||||
fun foo2(e1: E1, e2: E2) {
|
||||
when (e1) {
|
||||
E1.A -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>E2.A<!> -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>E2.B<!> -> {}
|
||||
e1 -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>e2<!> -> {}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
fun foo3(e1: Enum<E1>, e2: Enum<E2>, e: Enum<*>) {
|
||||
e1 == e
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == e2<!>
|
||||
|
||||
e1 == E1.A
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == E2.A<!>
|
||||
|
||||
when (e1) {
|
||||
e1 -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>e2<!> -> {}
|
||||
e -> {}
|
||||
E1.A -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>E2.A<!> -> {}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
when (e) {
|
||||
e -> {}
|
||||
e2 -> {}
|
||||
E1.A -> {}
|
||||
E2.A -> {}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: -ProhibitComparisonOfIncompatibleEnums
|
||||
|
||||
interface I {
|
||||
|
||||
@@ -9,13 +9,13 @@ enum class E2 {
|
||||
}
|
||||
|
||||
fun foo1(e1: E1, e2: E2) {
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == e2<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 != e2<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == e2<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 != e2<!>
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == E2.A<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>E1.B == e2<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == E2.A<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>E1.B == e2<!>
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>E1.A == E2.B<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>E1.A == E2.B<!>
|
||||
|
||||
e1 == E1.A
|
||||
E1.A == e1
|
||||
@@ -26,27 +26,27 @@ fun foo1(e1: E1, e2: E2) {
|
||||
fun foo2(e1: E1, e2: E2) {
|
||||
when (e1) {
|
||||
E1.A -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>E2.A<!> -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>E2.B<!> -> {}
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>E2.A<!> -> {}
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>E2.B<!> -> {}
|
||||
e1 -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>e2<!> -> {}
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e2<!> -> {}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
fun foo3(e1: Enum<E1>, e2: Enum<E2>, e: Enum<*>) {
|
||||
e1 == e
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == e2<!>
|
||||
e1 == e2
|
||||
|
||||
e1 == E1.A
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == E2.A<!>
|
||||
e1 == E2.A
|
||||
|
||||
when (e1) {
|
||||
e1 -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>e2<!> -> {}
|
||||
e2 -> {}
|
||||
e -> {}
|
||||
E1.A -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>E2.A<!> -> {}
|
||||
E2.A -> {}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
@@ -63,15 +63,15 @@ interface MyInterface
|
||||
open class MyOpenClass
|
||||
|
||||
fun foo4(e1: E1, i: MyInterface, c: MyOpenClass) {
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == i<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>i == e1<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == i<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>i == e1<!>
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == c<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>c == e1<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == c<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>c == e1<!>
|
||||
|
||||
when (e1) {
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>i<!> -> {}
|
||||
<!INCOMPATIBLE_TYPES_WARNING!>c<!> -> {}
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>i<!> -> {}
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>c<!> -> {}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -90,10 +90,10 @@ fun foo6(e1: E1?, e2: E2) {
|
||||
e1 == null
|
||||
null == e1
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == E2.A<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>E2.A == e1<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == e2<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e2 == e1<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == E2.A<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>E2.A == e1<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == e2<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e2 == e1<!>
|
||||
|
||||
<!SENSELESS_COMPARISON!>e2 == null<!>
|
||||
<!SENSELESS_COMPARISON!>null == e2<!>
|
||||
@@ -102,7 +102,7 @@ fun foo6(e1: E1?, e2: E2) {
|
||||
}
|
||||
|
||||
fun foo7(e1: E1?, e2: E2?) {
|
||||
e1 == e2 // There should be an IDE-inspection for such cases
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == e2<!> // There should be an IDE-inspection for such cases
|
||||
}
|
||||
|
||||
fun <T> foo8(e1: E1?, e2: E2, t: T) {
|
||||
@@ -117,16 +117,16 @@ fun <T> foo8(e1: E1?, e2: E2, t: T) {
|
||||
}
|
||||
|
||||
fun <T, K> foo9(e1: E1?, e2: E2, t: T, k: K) where T : MyInterface, T : MyOpenClass, K : MyInterface {
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == t<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>t == e1<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == t<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>t == e1<!>
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e2 == t<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>t == e2<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e2 == t<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>t == e2<!>
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>E1.A == t<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>t == E1.A<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>E1.A == t<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>t == E1.A<!>
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>E3.X == t<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>E3.X == t<!>
|
||||
|
||||
E3.X == k
|
||||
k == E3.X
|
||||
@@ -137,9 +137,9 @@ interface Inv<T>
|
||||
enum class E4 : Inv<Int> { A }
|
||||
|
||||
fun foo10(e4: E4, invString: Inv<String>) {
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e4 == invString<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>invString == e4<!>
|
||||
e4 == invString
|
||||
invString == e4
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>E4.A == invString<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>invString == E4.A<!>
|
||||
E4.A == invString
|
||||
invString == E4.A
|
||||
}
|
||||
|
||||
@@ -26,27 +26,27 @@ fun foo1(e1: E1, e2: E2) {
|
||||
fun foo2(e1: E1, e2: E2) {
|
||||
when (e1) {
|
||||
E1.A -> {}
|
||||
<!INCOMPATIBLE_TYPES!>E2.A<!> -> {}
|
||||
<!INCOMPATIBLE_TYPES!>E2.B<!> -> {}
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E2.A<!> -> {}
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E2.B<!> -> {}
|
||||
e1 -> {}
|
||||
<!INCOMPATIBLE_TYPES!>e2<!> -> {}
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e2<!> -> {}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
fun foo3(e1: Enum<E1>, e2: Enum<E2>, e: Enum<*>) {
|
||||
e1 == e
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == e2<!>
|
||||
e1 == e2
|
||||
|
||||
e1 == E1.A
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == E2.A<!>
|
||||
e1 == E2.A
|
||||
|
||||
when (e1) {
|
||||
e1 -> {}
|
||||
<!INCOMPATIBLE_TYPES!>e2<!> -> {}
|
||||
e2 -> {}
|
||||
e -> {}
|
||||
E1.A -> {}
|
||||
<!INCOMPATIBLE_TYPES!>E2.A<!> -> {}
|
||||
E2.A -> {}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
@@ -70,8 +70,8 @@ fun foo4(e1: E1, i: MyInterface, c: MyOpenClass) {
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>c == e1<!>
|
||||
|
||||
when (e1) {
|
||||
<!INCOMPATIBLE_TYPES!>i<!> -> {}
|
||||
<!INCOMPATIBLE_TYPES!>c<!> -> {}
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>i<!> -> {}
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>c<!> -> {}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ fun foo6(e1: E1?, e2: E2) {
|
||||
}
|
||||
|
||||
fun foo7(e1: E1?, e2: E2?) {
|
||||
e1 == e2 // There should be an IDE-inspection for such cases
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == e2<!> // There should be an IDE-inspection for such cases
|
||||
}
|
||||
|
||||
fun <T> foo8(e1: E1?, e2: E2, t: T) {
|
||||
@@ -117,16 +117,16 @@ fun <T> foo8(e1: E1?, e2: E2, t: T) {
|
||||
}
|
||||
|
||||
fun <T, K> foo9(e1: E1?, e2: E2, t: T, k: K) where T : MyInterface, T : MyOpenClass, K : MyInterface {
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == t<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>t == e1<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == t<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>t == e1<!>
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e2 == t<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>t == e2<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>e2 == t<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>t == e2<!>
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>E1.A == t<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>t == E1.A<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>E1.A == t<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>t == E1.A<!>
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>E3.X == t<!>
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON!>E3.X == t<!>
|
||||
|
||||
E3.X == k
|
||||
k == E3.X
|
||||
@@ -137,9 +137,9 @@ interface Inv<T>
|
||||
enum class E4 : Inv<Int> { A }
|
||||
|
||||
fun foo10(e4: E4, invString: Inv<String>) {
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>e4 == invString<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>invString == e4<!>
|
||||
e4 == invString
|
||||
invString == e4
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>E4.A == invString<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>invString == E4.A<!>
|
||||
E4.A == invString
|
||||
invString == E4.A
|
||||
}
|
||||
|
||||
@@ -56,47 +56,47 @@ fun foo(
|
||||
<!EQUALITY_NOT_APPLICABLE!>"" == 2<!>
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE!>string == int<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>strings == ints<!>
|
||||
strings == ints
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aString == aInt<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aOutString == aOutInt<!>
|
||||
aString == aInt
|
||||
aOutString == aOutInt
|
||||
aInString == aInInt
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aOutString == aInInt<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aInString == aOutInt<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aOutString == aInt<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aInString == aInt<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aOutString2 == aOutInt2<!>
|
||||
aOutString == aInInt
|
||||
aInString == aOutInt
|
||||
aOutString == aInt
|
||||
aInString == aInt
|
||||
aOutString2 == aOutInt2
|
||||
aInString2 == aInInt2
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aOutString2 == aInInt2<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aInString2 == aOutInt2<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aString == a2<!>
|
||||
aOutString2 == aInInt2
|
||||
aInString2 == aOutInt2
|
||||
aString == a2
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>bString == bInt<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>bOutString == bOutInt<!>
|
||||
bString == bInt
|
||||
bOutString == bOutInt
|
||||
bInString == bInInt
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>bOutString == bInInt<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>bInString == bOutInt<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>bOutString == bInt<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>bInString == bInt<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>bOutString2 == bOutInt2<!>
|
||||
bOutString == bInInt
|
||||
bInString == bOutInt
|
||||
bOutString == bInt
|
||||
bInString == bInt
|
||||
bOutString2 == bOutInt2
|
||||
bInString2 == bInInt2
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>bOutString2 == bInInt2<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>bInString2 == bOutInt2<!>
|
||||
bOutString2 == bInInt2
|
||||
bInString2 == bOutInt2
|
||||
|
||||
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e == i<!>
|
||||
<!EQUALITY_NOT_APPLICABLE!>"" == i<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>ac == ad<!>
|
||||
ac == ad
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>tSub1 == tSub2<!>
|
||||
tSub1 == tSub2
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aString == bString<!>
|
||||
aString == bString
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aListInt == aSetInt<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aSetInt == aListString<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aListString == aListInt<!>
|
||||
aListInt == aSetInt
|
||||
aSetInt == aListString
|
||||
aListString == aListInt
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>aString == aListString<!>
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>bString == aListString<!>
|
||||
aString == aListString
|
||||
bString == aListString
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE_WARNING!>mutableListAny == listString<!>
|
||||
mutableListAny == listString
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user