ConeTypeCompatibilityChecker: add temporary workaround for KT-46383
This commit is contained in:
committed by
teamcityserver
parent
db55a973d4
commit
1936a815e2
+10
-6
@@ -68,12 +68,16 @@ internal object ConeTypeCompatibilityChecker {
|
||||
if (all { with(ctx) { it.isNullableType() } }) return Compatibility.COMPATIBLE
|
||||
|
||||
// Next can simply focus on the type hierarchy and don't need to worry about nullability.
|
||||
val compatibilityUpperBound = if (this.all { it.isConcreteType() }) {
|
||||
Compatibility.HARD_INCOMPATIBLE
|
||||
} else {
|
||||
// If any type is not concrete, for example, type parameter, we only report warning for incompatible types. This is to stay
|
||||
// compatible with FE1.0.
|
||||
Compatibility.SOFT_INCOMPATIBLE
|
||||
val compatibilityUpperBound = when {
|
||||
all {
|
||||
it.classId in StandardClassIds.primitiveTypes
|
||||
} -> Compatibility.SOFT_INCOMPATIBLE // TODO: remove after KT-46383 is fixed
|
||||
all {
|
||||
it.isConcreteType()
|
||||
} -> Compatibility.HARD_INCOMPATIBLE
|
||||
// If any type is not concrete, for example, type parameter, we only report warning for incompatible types.
|
||||
// This is to stay compatible with FE1.0.
|
||||
else -> Compatibility.SOFT_INCOMPATIBLE
|
||||
}
|
||||
return ctx.areCompatible(flatMap { it.collectUpperBounds() }.toSet(), emptySet(), compatibilityUpperBound)
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ val test_dd = d === d || d !== d
|
||||
val test_cc = c === c || c !== c
|
||||
|
||||
// Identity for primitive values of different types (no extra error)
|
||||
val test_zb = <!EQUALITY_NOT_APPLICABLE!>z === b<!> || <!EQUALITY_NOT_APPLICABLE!>z !== b<!>
|
||||
val test_zb = <!EQUALITY_NOT_APPLICABLE_WARNING!>z === b<!> || <!EQUALITY_NOT_APPLICABLE_WARNING!>z !== b<!>
|
||||
|
||||
// Primitive vs nullable
|
||||
val test_znz = z === nz || nz === z || z !== nz || nz !== z
|
||||
|
||||
@@ -344,7 +344,7 @@ fun case_20(b: Boolean) {
|
||||
|
||||
// TESTCASE NUMBER: 21
|
||||
fun case_21() {
|
||||
if (<!EQUALITY_NOT_APPLICABLE!>EnumClassWithNullableProperty.B.prop_1 !== null is Boolean<!> == <!USELESS_IS_CHECK!>true !is Boolean<!> != true) {
|
||||
if (<!EQUALITY_NOT_APPLICABLE_WARNING!>EnumClassWithNullableProperty.B.prop_1 !== null is Boolean<!> == <!USELESS_IS_CHECK!>true !is Boolean<!> != true) {
|
||||
EnumClassWithNullableProperty.B.prop_1
|
||||
EnumClassWithNullableProperty.B.prop_1<!UNSAFE_CALL!>.<!>equals(null)
|
||||
EnumClassWithNullableProperty.B.prop_1.propT
|
||||
@@ -376,7 +376,7 @@ fun case_22(a: (() -> Unit)?) {
|
||||
|
||||
// TESTCASE NUMBER: 23
|
||||
fun case_23(a: ((Float) -> Int?)?, b: Float?) {
|
||||
if (<!EQUALITY_NOT_APPLICABLE!>a != null !is Boolean<!> && <!EQUALITY_NOT_APPLICABLE!>b !== null is Boolean<!>) {
|
||||
if (<!EQUALITY_NOT_APPLICABLE!>a != null !is Boolean<!> && <!EQUALITY_NOT_APPLICABLE_WARNING!>b !== null is Boolean<!>) {
|
||||
val x = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!><!UNSAFE_IMPLICIT_INVOKE_CALL!>a<!>(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Float?")!>b<!>)<!>
|
||||
if (x != null) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>
|
||||
|
||||
Reference in New Issue
Block a user