From 6607c8a0569e3893d781a2e34b37e1b3be32da13 Mon Sep 17 00:00:00 2001 From: Nikolay Lunyak Date: Mon, 26 Feb 2024 18:06:50 +0200 Subject: [PATCH] [FIR] Allow `Int? === null` It was decided to allow this comparison duting the last DM. ^KT-62646 --- .../FirEqualityCompatibilityChecker.kt | 1 + .../stubTypes/memberScope.fir.kt | 30 +-- .../equalityCompatibilityCommonCases.fir.kt | 2 +- ...qualityCompatibilityOldBehavior_Off.fir.kt | 2 +- ...equalityCompatibilityOldBehavior_On.fir.kt | 2 +- .../diagnostics/notLinked/dfa/neg/1.fir.kt | 20 +- .../diagnostics/notLinked/dfa/neg/15.fir.kt | 2 +- .../diagnostics/notLinked/dfa/pos/1.fir.kt | 186 +++++++++--------- .../diagnostics/notLinked/dfa/pos/16.fir.kt | 6 +- .../diagnostics/notLinked/dfa/pos/17.fir.kt | 2 +- .../diagnostics/notLinked/dfa/pos/18.fir.kt | 6 +- .../diagnostics/notLinked/dfa/pos/28.fir.kt | 28 +-- .../diagnostics/notLinked/dfa/pos/3.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/4.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/5.fir.kt | 2 +- .../diagnostics/notLinked/dfa/pos/59.fir.kt | 8 +- .../diagnostics/notLinked/dfa/pos/6.fir.kt | 22 +-- .../diagnostics/notLinked/dfa/pos/7.fir.kt | 16 +- 18 files changed, 172 insertions(+), 171 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirEqualityCompatibilityChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirEqualityCompatibilityChecker.kt index 27184d3860a..9648ab730d7 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirEqualityCompatibilityChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirEqualityCompatibilityChecker.kt @@ -103,6 +103,7 @@ object FirEqualityCompatibilityChecker : FirEqualityOperatorCallChecker(MppCheck val oneIsNotNull = !l.type.isNullable || !r.type.isNullable return when { + l.type.isNullableNothing || r.type.isNullableNothing -> Applicability.APPLICABLE l.isIdentityLess || r.isIdentityLess -> Applicability.INAPPLICABLE_AS_IDENTITY_LESS oneIsNotNull && shouldReportAsPerRules1(l, r, context) -> getInapplicabilityFor(l, r) else -> Applicability.APPLICABLE diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/memberScope.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/memberScope.fir.kt index 18569cf1a7b..c35c493a507 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/memberScope.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/memberScope.fir.kt @@ -55,7 +55,7 @@ fun test() { x?.equals(1) if (get() == null) {} - if (get() === null) {} + if (get() === null) {} if (x != null) { x?.hashCode() @@ -114,7 +114,7 @@ fun test() { emit(1) emit(null) val x = get() - if (x === null) { + if (x === null) { x.hashCode() } @@ -124,7 +124,7 @@ fun test() { emit(1) emit(null) val x = get() - if (x === null) { + if (x === null) { x.equals("") } @@ -134,7 +134,7 @@ fun test() { emit(1) emit(null) val x = get() - if (x === null) { + if (x === null) { x.toString("") } @@ -144,7 +144,7 @@ fun test() { emit(1) emit(null) val x = get() - if (x === null) { + if (x === null) { x.test() } @@ -171,7 +171,7 @@ fun test() { x?.equals(1) if (get() == null) {} - if (get() === null) {} + if (get() === null) {} if (x == null) { x?.hashCode() @@ -189,19 +189,19 @@ fun test() { x.test2() } - if (x === null) { + if (x === null) { x?.hashCode() } - if (x === null) { + if (x === null) { x?.equals(1) } - if (x === null) { + if (x === null) { x?.test2() } - if (x === null) { + if (x === null) { x.test2() } @@ -248,7 +248,7 @@ fun test() { emit(1) emit(null) val x = get() - if (x === null) { + if (x === null) { x.equals("") } @@ -258,7 +258,7 @@ fun test() { emit(1) emit(null) val x = get() - if (x === null) { + if (x === null) { x.hashCode() } "" @@ -267,7 +267,7 @@ fun test() { emit(1) emit(null) val x = get() - if (x === null) { + if (x === null) { x.toString() } "" @@ -276,7 +276,7 @@ fun test() { emit(1) emit(null) val x = get() - if (x === null) { + if (x === null) { x.test() } "" @@ -301,7 +301,7 @@ fun test() { x?.equals(1) if (get() == null) {} - if (get() === null) {} + if (get() === null) {} if (x == null) { x?.hashCode() diff --git a/compiler/testData/diagnostics/testsWithStdLib/equalityCompatibilityCommonCases.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/equalityCompatibilityCommonCases.fir.kt index 748ff683e96..971e9bebb55 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/equalityCompatibilityCommonCases.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/equalityCompatibilityCommonCases.fir.kt @@ -87,7 +87,7 @@ fun incompatibleIdentityRegardlessNullabilitySmartCast(a: Any?, b: Any?) { fun incompatibleIdentityRegardlessNullabilityWithNull(a: Int?) { a == null - a === null + a === null } fun incompatibleIdentityRegardlessNullabilityWithValueClasses(c: C?, d: D?) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/equalityCompatibilityOldBehavior_Off.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/equalityCompatibilityOldBehavior_Off.fir.kt index 2f7bf5a91c5..8fc056db519 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/equalityCompatibilityOldBehavior_Off.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/equalityCompatibilityOldBehavior_Off.fir.kt @@ -1,7 +1,7 @@ // LANGUAGE: +ReportErrorsForComparisonOperators fun nullableNothingIdentity(a: Int, b: Nothing?) { - a === b + a === b } fun samePrimitiveIdentity(a: Int, b: Int) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/equalityCompatibilityOldBehavior_On.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/equalityCompatibilityOldBehavior_On.fir.kt index 753d62dca33..da87a06e6f7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/equalityCompatibilityOldBehavior_On.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/equalityCompatibilityOldBehavior_On.fir.kt @@ -1,7 +1,7 @@ // LANGUAGE: -ReportErrorsForComparisonOperators fun nullableNothingIdentity(a: Int, b: Nothing?) { - a === b + a === b } fun samePrimitiveIdentity(a: Int, b: Int) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt index 76de8c4006e..b22ca7c06cd 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt @@ -29,7 +29,7 @@ fun case_1(x: Any?) { // TESTCASE NUMBER: 3 fun case_3() { - if (Object.prop_1 == null !== null) + if (Object.prop_1 == null !== null) else { Object.prop_1 Object.prop_1.equals(null) @@ -112,13 +112,13 @@ fun case_7() { // TESTCASE NUMBER: 8 fun case_8(x: TypealiasNullableString) { - if (x !== null === null && x != null != null) x.get(0) - if (x !== null != null && x != null === null) x.get(0) + if (x !== null === null && x != null != null) x.get(0) + if (x !== null != null && x != null === null) x.get(0) } // TESTCASE NUMBER: 9 fun case_9(x: TypealiasNullableString?) { - if (x === null === null) { + if (x === null === null) { } else if (false is Boolean) { x @@ -130,8 +130,8 @@ fun case_9(x: TypealiasNullableString?) { fun case_10() { val a = Class() - if (a.prop_4 === null || true is Boolean) { - if (a.prop_4 != null !== null) { + if (a.prop_4 === null || true is Boolean) { + if (a.prop_4 != null !== null) { a.prop_4 a.prop_4.equals(null) a.prop_4.propT @@ -175,7 +175,7 @@ fun case_11(x: TypealiasNullableStringIndirect?, y: Typ // TESTCASE NUMBER: 12 fun case_12(x: TypealiasNullableStringIndirect, y: TypealiasNullableStringIndirect) = if ((x == null) !is Boolean === false) "1" - else if ((y === null !== null) is Boolean) x + else if ((y === null !== null) is Boolean) x else if (y === null != null) x.equals(null) else if (y === null != null) x.propT else if (y === null != null) x.propAny @@ -212,7 +212,7 @@ fun case_14() { if (a.x != null == true) { if (a.x !== null == false) { if (a.x != null == null) { - if (a.x != null !== null) { + if (a.x != null !== null) { if (a.x != null === true) { if (a.x !== null === true !is Boolean == true) { if (a.x != null !== false) { @@ -278,7 +278,7 @@ val case_17 = if (nullableIntProperty == null == true == false) 0 else { //TESTCASE NUMBER: 18 fun case_18(a: DeepObject.A.B.C.D.E.F.G.J?) { - if (a != null !== null) { + if (a != null !== null) { a a.equals(null) a.propT @@ -312,7 +312,7 @@ fun case_19(b: Boolean) { } } else null - if (a != null !is Boolean && a.B19 != null is Boolean && a.B19.C19 != null is Boolean && a.B19.C19.D19 != null == null && a.B19.C19.D19.x != null !== null) { + if (a != null !is Boolean && a.B19 != null is Boolean && a.B19.C19 != null is Boolean && a.B19.C19.D19 != null == null && a.B19.C19.D19.x != null !== null) { a.B19.C19.D19.x a.B19.C19.D19.x.equals(null) a.B19.C19.D19.x.propT diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt index 5e2740bcb39..b5a05aa4e1c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt @@ -30,7 +30,7 @@ fun case_1() { */ fun case_2() { var x: Boolean? = true - if (x !== null && try { x = null; true } catch (e: Exception) { false }) { + if (x !== null && try { x = null; true } catch (e: Exception) { false }) { x x.not() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt index aac2e518a43..aafa86d1dae 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt @@ -172,7 +172,7 @@ fun case_9(x: TypealiasNullableString?) { fun case_10() { val a = Class() - if (a.prop_4 === null || true) { + if (a.prop_4 === null || true) { if (a.prop_4 != null) { a.prop_4 a.prop_4.equals(null) @@ -418,7 +418,7 @@ fun case_20(b: Boolean) { // TESTCASE NUMBER: 21 fun case_21() { - if (EnumClassWithNullableProperty.B.prop_1 !== null) { + if (EnumClassWithNullableProperty.B.prop_1 !== null) { EnumClassWithNullableProperty.B.prop_1 EnumClassWithNullableProperty.B.prop_1.equals(null) EnumClassWithNullableProperty.B.prop_1.propT @@ -450,7 +450,7 @@ fun case_22(a: (() -> Unit)?) { // TESTCASE NUMBER: 23 fun case_23(a: ((Float) -> Int?)?, b: Float?) { - if (a != null && b !== null) { + if (a != null && b !== null) { val x = a(b) if (x != null) { x @@ -1534,36 +1534,36 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: } fun case_29(a: Case29) { - if (a.x !== null) a.x.equals(null) - if (a.x !== null) a.x.propT - if (a.x !== null) a.x.propAny - if (a.x !== null) a.x.propNullableT - if (a.x !== null) a.x.propNullableAny - if (a.x !== null) a.x.funT() - if (a.x !== null) a.x.funAny() - if (a.x !== null) a.x.funNullableT() - if (a.x !== null) a.x.funNullableAny() - if (a.x !== null) a.x - if (a.b !== null) a.b.equals(null) - if (a.b !== null) a.b.propT - if (a.b !== null) a.b.propAny - if (a.b !== null) a.b.propNullableT - if (a.b !== null) a.b.propNullableAny - if (a.b !== null) a.b.funT() - if (a.b !== null) a.b.funAny() - if (a.b !== null) a.b.funNullableT() - if (a.b !== null) a.b.funNullableAny() - if (a.b !== null) a.b - if (a.e !== null) a.e.equals(null) - if (a.e !== null) a.e.propT - if (a.e !== null) a.e.propAny - if (a.e !== null) a.e.propNullableT - if (a.e !== null) a.e.propNullableAny - if (a.e !== null) a.e.funT() - if (a.e !== null) a.e.funAny() - if (a.e !== null) a.e.funNullableT() - if (a.e !== null) a.e.funNullableAny() - if (a.e !== null) a.e + if (a.x !== null) a.x.equals(null) + if (a.x !== null) a.x.propT + if (a.x !== null) a.x.propAny + if (a.x !== null) a.x.propNullableT + if (a.x !== null) a.x.propNullableAny + if (a.x !== null) a.x.funT() + if (a.x !== null) a.x.funAny() + if (a.x !== null) a.x.funNullableT() + if (a.x !== null) a.x.funNullableAny() + if (a.x !== null) a.x + if (a.b !== null) a.b.equals(null) + if (a.b !== null) a.b.propT + if (a.b !== null) a.b.propAny + if (a.b !== null) a.b.propNullableT + if (a.b !== null) a.b.propNullableAny + if (a.b !== null) a.b.funT() + if (a.b !== null) a.b.funAny() + if (a.b !== null) a.b.funNullableT() + if (a.b !== null) a.b.funNullableAny() + if (a.b !== null) a.b + if (a.e !== null) a.e.equals(null) + if (a.e !== null) a.e.propT + if (a.e !== null) a.e.propAny + if (a.e !== null) a.e.propNullableT + if (a.e !== null) a.e.propNullableAny + if (a.e !== null) a.e.funT() + if (a.e !== null) a.e.funAny() + if (a.e !== null) a.e.funNullableT() + if (a.e !== null) a.e.funNullableAny() + if (a.e !== null) a.e if (a.f !== null) a.f.equals(null) if (a.f !== null) a.f.propT if (a.f !== null) a.f.propAny @@ -2578,36 +2578,36 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val } fun case_30(a: Case30) { - if (a.x !== null) a.x.equals(null) - if (a.x !== null) a.x.propT - if (a.x !== null) a.x.propAny - if (a.x !== null) a.x.propNullableT - if (a.x !== null) a.x.propNullableAny - if (a.x !== null) a.x.funT() - if (a.x !== null) a.x.funAny() - if (a.x !== null) a.x.funNullableT() - if (a.x !== null) a.x.funNullableAny() - if (a.x !== null) a.x - if (a.b !== null) a.b.equals(null) - if (a.b !== null) a.b.propT - if (a.b !== null) a.b.propAny - if (a.b !== null) a.b.propNullableT - if (a.b !== null) a.b.propNullableAny - if (a.b !== null) a.b.funT() - if (a.b !== null) a.b.funAny() - if (a.b !== null) a.b.funNullableT() - if (a.b !== null) a.b.funNullableAny() - if (a.b !== null) a.b - if (a.e !== null) a.e.equals(null) - if (a.e !== null) a.e.propT - if (a.e !== null) a.e.propAny - if (a.e !== null) a.e.propNullableT - if (a.e !== null) a.e.propNullableAny - if (a.e !== null) a.e.funT() - if (a.e !== null) a.e.funAny() - if (a.e !== null) a.e.funNullableT() - if (a.e !== null) a.e.funNullableAny() - if (a.e !== null) a.e + if (a.x !== null) a.x.equals(null) + if (a.x !== null) a.x.propT + if (a.x !== null) a.x.propAny + if (a.x !== null) a.x.propNullableT + if (a.x !== null) a.x.propNullableAny + if (a.x !== null) a.x.funT() + if (a.x !== null) a.x.funAny() + if (a.x !== null) a.x.funNullableT() + if (a.x !== null) a.x.funNullableAny() + if (a.x !== null) a.x + if (a.b !== null) a.b.equals(null) + if (a.b !== null) a.b.propT + if (a.b !== null) a.b.propAny + if (a.b !== null) a.b.propNullableT + if (a.b !== null) a.b.propNullableAny + if (a.b !== null) a.b.funT() + if (a.b !== null) a.b.funAny() + if (a.b !== null) a.b.funNullableT() + if (a.b !== null) a.b.funNullableAny() + if (a.b !== null) a.b + if (a.e !== null) a.e.equals(null) + if (a.e !== null) a.e.propT + if (a.e !== null) a.e.propAny + if (a.e !== null) a.e.propNullableT + if (a.e !== null) a.e.propNullableAny + if (a.e !== null) a.e.funT() + if (a.e !== null) a.e.funAny() + if (a.e !== null) a.e.funNullableT() + if (a.e !== null) a.e.funNullableAny() + if (a.e !== null) a.e if (a.f !== null) a.f.equals(null) if (a.f !== null) a.f.propT if (a.f !== null) a.f.propAny @@ -3623,36 +3623,36 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: } fun case_31(a: Case31) { - if (a.x !== null) a.x.equals(null) - if (a.x !== null) a.x.propT - if (a.x !== null) a.x.propAny - if (a.x !== null) a.x.propNullableT - if (a.x !== null) a.x.propNullableAny - if (a.x !== null) a.x.funT() - if (a.x !== null) a.x.funAny() - if (a.x !== null) a.x.funNullableT() - if (a.x !== null) a.x.funNullableAny() - if (a.x !== null) a.x - if (a.b !== null) a.b.equals(null) - if (a.b !== null) a.b.propT - if (a.b !== null) a.b.propAny - if (a.b !== null) a.b.propNullableT - if (a.b !== null) a.b.propNullableAny - if (a.b !== null) a.b.funT() - if (a.b !== null) a.b.funAny() - if (a.b !== null) a.b.funNullableT() - if (a.b !== null) a.b.funNullableAny() - if (a.b !== null) a.b - if (a.e !== null) a.e.equals(null) - if (a.e !== null) a.e.propT - if (a.e !== null) a.e.propAny - if (a.e !== null) a.e.propNullableT - if (a.e !== null) a.e.propNullableAny - if (a.e !== null) a.e.funT() - if (a.e !== null) a.e.funAny() - if (a.e !== null) a.e.funNullableT() - if (a.e !== null) a.e.funNullableAny() - if (a.e !== null) a.e + if (a.x !== null) a.x.equals(null) + if (a.x !== null) a.x.propT + if (a.x !== null) a.x.propAny + if (a.x !== null) a.x.propNullableT + if (a.x !== null) a.x.propNullableAny + if (a.x !== null) a.x.funT() + if (a.x !== null) a.x.funAny() + if (a.x !== null) a.x.funNullableT() + if (a.x !== null) a.x.funNullableAny() + if (a.x !== null) a.x + if (a.b !== null) a.b.equals(null) + if (a.b !== null) a.b.propT + if (a.b !== null) a.b.propAny + if (a.b !== null) a.b.propNullableT + if (a.b !== null) a.b.propNullableAny + if (a.b !== null) a.b.funT() + if (a.b !== null) a.b.funAny() + if (a.b !== null) a.b.funNullableT() + if (a.b !== null) a.b.funNullableAny() + if (a.b !== null) a.b + if (a.e !== null) a.e.equals(null) + if (a.e !== null) a.e.propT + if (a.e !== null) a.e.propAny + if (a.e !== null) a.e.propNullableT + if (a.e !== null) a.e.propNullableAny + if (a.e !== null) a.e.funT() + if (a.e !== null) a.e.funAny() + if (a.e !== null) a.e.funNullableT() + if (a.e !== null) a.e.funNullableAny() + if (a.e !== null) a.e if (a.f !== null) a.f.equals(null) if (a.f !== null) a.f.propT if (a.f !== null) a.f.propAny diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/16.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/16.fir.kt index 097ef62fdab..e8eee0b936b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/16.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/16.fir.kt @@ -123,7 +123,7 @@ fun case_9(x: String?) { // TESTCASE NUMBER: 10 fun case_10(x: Float?) { - if (true && true && true && x !== null) else return + if (true && true && true && x !== null) else return x x.equals(null) x.propT @@ -474,7 +474,7 @@ fun case_33(x: Any?) { // TESTCASE NUMBER: 34 fun case_34(x: Float?) { (l@ { - if (true && true && true && x !== null) else return@l + if (true && true && true && x !== null) else return@l x x.equals(null) x.propT @@ -486,7 +486,7 @@ fun case_34(x: Float?) { x.funNullableT() x.funNullableAny() }).equals(l@ { - if (true && true && true && x !== null) else return@l + if (true && true && true && x !== null) else return@l x x.equals(null) x.propT diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/17.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/17.fir.kt index e74aaf1748a..5096525110c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/17.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/17.fir.kt @@ -122,7 +122,7 @@ fun case_9(x: String?) { // TESTCASE NUMBER: 10 fun case_10(x: Float?) { - if (true && true && true && x !== null) else throw Exception() + if (true && true && true && x !== null) else throw Exception() x x.equals(null) x.propT diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/18.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/18.fir.kt index 6e4f4334a2f..8c3534d9e91 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/18.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/18.fir.kt @@ -133,7 +133,7 @@ fun case_9(list: List) { // TESTCASE NUMBER: 10 fun case_10(x: Float?) { while (false) { - if (true && true && true && x !== null) else break + if (true && true && true && x !== null) else break x x.equals(null) x.propT @@ -167,7 +167,7 @@ fun case_11(x: Out<*>?, list: List) { // TESTCASE NUMBER: 12 fun case_12(list: List) { for (element in list) { - if (element === null) continue + if (element === null) continue element element.inv() } @@ -222,7 +222,7 @@ fun case_15(map: MutableMap, y: Nothing?) { // TESTCASE NUMBER: 16 fun case_16(map: Map) { for ((k, v) in map) { - if (k !== implicitNullableNothingProperty && v !== implicitNullableNothingProperty) else { continue } + if (k !== implicitNullableNothingProperty && v !== implicitNullableNothingProperty) else { continue } k k.inv() v diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/28.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/28.fir.kt index 77a67b9e1a5..b8550b706f0 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/28.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/28.fir.kt @@ -68,7 +68,7 @@ fun case_7(x: DeepObject.A.B.C.D.E.F.G.J?) { // TESTCASE NUMBER: 8 fun case_8(x: Any?) { - if (x?.equals(10) === null) else { + if (x?.equals(10) === null) else { x x.equals(10) } @@ -76,7 +76,7 @@ fun case_8(x: Any?) { // TESTCASE NUMBER: 9 fun case_9(x: Any?) { - if (x?.equals(10) !== null) { + if (x?.equals(10) !== null) { x x.equals(10) } @@ -126,7 +126,7 @@ inline fun case_13(x: Any?) { // TESTCASE NUMBER: 14 inline fun case_14(x: Any?) { - if (x?.equals(10) === null) else { + if (x?.equals(10) === null) else { x x.equals(10) } @@ -134,7 +134,7 @@ inline fun case_14(x: Any?) { // TESTCASE NUMBER: 15 inline fun case_15(x: Any?) { - if (x?.equals(10) !== null) { + if (x?.equals(10) !== null) { x x.equals(10) } @@ -146,7 +146,7 @@ inline fun case_15(x: Any?) { * ISSUES: KT-30369, KT-28262 */ inline fun case_16(x: Any?) { - if (x?.equals(10) === null == true) else { + if (x?.equals(10) === null == true) else { x x.equals(10) } @@ -158,7 +158,7 @@ inline fun case_16(x: Any?) { * ISSUES: KT-30369, KT-28262 */ inline fun case_17(x: Any?) { - if (x?.equals(10) !== null == true) { + if (x?.equals(10) !== null == true) { x x.equals(10) } @@ -170,7 +170,7 @@ inline fun case_17(x: Any?) { * ISSUES: KT-30369, KT-28262, KT-29878 */ inline fun case_18(x: Any?) { - if (x?.equals(10) === null === true) else { + if (x?.equals(10) === null === true) else { x x.equals(10) } @@ -182,7 +182,7 @@ inline fun case_18(x: Any?) { * ISSUES: KT-30369, KT-28262, KT-29878 */ inline fun case_19(x: Any?) { - if (x?.equals(10) !== null === true) { + if (x?.equals(10) !== null === true) { x x.equals(10) } @@ -194,7 +194,7 @@ inline fun case_19(x: Any?) { * ISSUES: KT-30369, KT-28262, KT-29878 */ inline fun case_20(x: Any?) { - if (x?.equals(10) === null !== false) else { + if (x?.equals(10) === null !== false) else { x x.equals(10) } @@ -206,7 +206,7 @@ inline fun case_20(x: Any?) { * ISSUES: KT-30369, KT-28262, KT-29878 */ inline fun case_21(x: Any?) { - if (x?.equals(10) !== null !== false) { + if (x?.equals(10) !== null !== false) { x x.equals(10) } @@ -218,7 +218,7 @@ inline fun case_21(x: Any?) { * ISSUES: KT-30369, KT-28262, KT-29878 */ inline fun case_22(x: Any?) { - if (x?.equals(10) !== null !== true) else { + if (x?.equals(10) !== null !== true) else { x x.equals(10) } @@ -230,7 +230,7 @@ inline fun case_22(x: Any?) { * ISSUES: KT-30369, KT-28262, KT-29878 */ inline fun case_23(x: Any?) { - if (x?.equals(10) === null === false) { + if (x?.equals(10) === null === false) { x x.equals(10) } @@ -242,7 +242,7 @@ inline fun case_23(x: Any?) { * ISSUES: KT-30369, KT-28262 */ inline fun case_24(x: Any?) { - if (x?.equals(10) !== null != true) else { + if (x?.equals(10) !== null != true) else { x x.equals(10) } @@ -254,7 +254,7 @@ inline fun case_24(x: Any?) { * ISSUES: KT-30369, KT-28262 */ inline fun case_25(x: Any?) { - if (x?.equals(10) === null == false) { + if (x?.equals(10) === null == false) { x x.equals(10) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/3.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/3.fir.kt index d7188954886..05fbe57603d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/3.fir.kt @@ -195,7 +195,7 @@ fun case_16() { } // TESTCASE NUMBER: 17 -val case_17 = if (nullableIntProperty !== null) 0 else { +val case_17 = if (nullableIntProperty !== null) 0 else { nullableIntProperty } @@ -305,7 +305,7 @@ fun case_25(b: Boolean) { } // TESTCASE NUMBER: 26 -fun case_26(a: Int?, b: Int? = if (a !== null) 0 else a) { +fun case_26(a: Int?, b: Int? = if (a !== null) 0 else a) { a b } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt index ce93cb7384d..d2fcc3baf22 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt @@ -265,7 +265,7 @@ fun case_22(a: (() -> Unit)) { fun case_23(a: ((Float) -> Int), b: Float) { if (a == null && b == null) { val x = a(b) - if (x !== null) { + if (x !== null) { x } } @@ -290,7 +290,7 @@ fun case_25(a: (() -> Unit) -> Unit, b: (() -> Unit) -> Unit = if (a === null) a else 0) { +fun case_26(a: Int, b: Int = if (a === null) a else 0) { a b } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/5.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/5.fir.kt index ae007c2a83c..3bc3273b020 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/5.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/5.fir.kt @@ -360,7 +360,7 @@ fun case_15(x: Any?) { } // TESTCASE NUMBER: 16 -fun case_16(a: Any?, b: Int = if (a is Number? && a is Int? && a !== null) a else 0) { +fun case_16(a: Any?, b: Int = if (a is Number? && a is Int? && a !== null) a else 0) { a b b.equals(null) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/59.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/59.fir.kt index 0e89ef24aaf..4f2774dd0fc 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/59.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/59.fir.kt @@ -35,7 +35,7 @@ fun case_2() { do { x x = x.equals(10) - } while (x !== null) + } while (x !== null) } // TESTCASE NUMBER: 3 @@ -67,7 +67,7 @@ fun case_5() { do { x x = x.equals(10) - } while (x !== null) + } while (x !== null) } /* @@ -95,7 +95,7 @@ fun case_7() { do { x x = x.equals(10) - } while (x !== null) + } while (x !== null) } /* @@ -123,7 +123,7 @@ fun case_9() { do { x x = x.equals(10) - } while (x !== null) + } while (x !== null) } /* diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt index fa261b8585b..c44316d9061 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt @@ -183,7 +183,7 @@ fun case_10() { val a = Class() val b = null - if (a.prop_4 === b || true) { + if (a.prop_4 === b || true) { if (a.prop_4 != null) { a.prop_4 a.prop_4.equals(null) @@ -315,7 +315,7 @@ fun case_16() { } // TESTCASE NUMBER: 17 -val case_17 = if (nullableIntProperty === implicitNullableNothingProperty) 0 else { +val case_17 = if (nullableIntProperty === implicitNullableNothingProperty) 0 else { nullableIntProperty nullableIntProperty.equals(null) nullableIntProperty.propT @@ -413,7 +413,7 @@ fun case_20(x: Boolean, y: Nothing?) { // TESTCASE NUMBER: 21 fun case_21() { - if (EnumClassWithNullableProperty.A.prop_1 !== implicitNullableNothingProperty) { + if (EnumClassWithNullableProperty.A.prop_1 !== implicitNullableNothingProperty) { EnumClassWithNullableProperty.A.prop_1 EnumClassWithNullableProperty.A.prop_1.equals(null) EnumClassWithNullableProperty.A.prop_1.propT @@ -445,9 +445,9 @@ fun case_22(a: (() -> Unit)?) { // TESTCASE NUMBER: 23 fun case_23(a: ((Float) -> Int?)?, b: Float?, z: Nothing?) { - if (a != z && b !== z && b !== z) { + if (a != z && b !== z && b !== z) { val x = a(b) - if (x != z || x !== implicitNullableNothingProperty) { + if (x != z || x !== implicitNullableNothingProperty) { x x.equals(null) x.propT @@ -520,7 +520,7 @@ fun case_26(a: ((Float) -> Int?)?, b: Float?) { if (a != z == true && b != implicitNullableNothingProperty == true) { val x = a(b) - if (x != implicitNullableNothingProperty == true || z !== x) { + if (x != implicitNullableNothingProperty == true || z !== x) { x x.equals(null) x.propT @@ -621,7 +621,7 @@ fun case_30(a: ((Float) -> Int?)?, b: Float?) { // TESTCASE NUMBER: 31 fun case_31(z1: Boolean?, z: Nothing?) { - if (false || EnumClassWithNullableProperty.A.prop_1 != z && z1 !== z && z1) { + if (false || EnumClassWithNullableProperty.A.prop_1 != z && z1 !== z && z1) { EnumClassWithNullableProperty.A.prop_1 EnumClassWithNullableProperty.A.prop_1.equals(null) EnumClassWithNullableProperty.A.prop_1.propT @@ -660,7 +660,7 @@ fun case_33(a: ((Float) -> Int?)?, b: Float?, c: Boolean?) { } else { val x = a(b) - if (x == z == true && x === z || (c != z && !c)) { + if (x == z == true && x === z || (c != z && !c)) { } else { x @@ -685,7 +685,7 @@ fun case_33(a: ((Float) -> Int?)?, b: Float?, c: Boolean?) { fun case_34(z1: Boolean?) { var z = null - if (true && true && true && true && EnumClassWithNullableProperty.A.prop_1 != implicitNullableNothingProperty && EnumClassWithNullableProperty.A.prop_1 !== null && EnumClassWithNullableProperty.A.prop_1 !== z || z1 != implicitNullableNothingProperty || z1!! && true && true) { + if (true && true && true && true && EnumClassWithNullableProperty.A.prop_1 != implicitNullableNothingProperty && EnumClassWithNullableProperty.A.prop_1 !== null && EnumClassWithNullableProperty.A.prop_1 !== z || z1 != implicitNullableNothingProperty || z1!! && true && true) { } else { EnumClassWithNullableProperty.A.prop_1 @@ -925,7 +925,7 @@ fun case_51() { } // TESTCASE NUMBER: 52 -val case_52 = if (nullableIntProperty !== nullableNothingProperty && nullableNothingProperty != nullableIntProperty) 0 else { +val case_52 = if (nullableIntProperty !== nullableNothingProperty && nullableNothingProperty != nullableIntProperty) 0 else { nullableIntProperty nullableIntProperty.hashCode() } @@ -1011,7 +1011,7 @@ fun case_57(a: (() -> Unit)) { * UNEXPECTED BEHAVIOUR */ fun case_58(a: ((Float) -> Int?)?, b: Float?, z: Nothing?) { - if (a === z && b == z || z == a && z === b) { + if (a === z && b == z || z == a && z === b) { ?")!>a b if (a != z) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt index 8bccc41ce91..69e5f3965af 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt @@ -178,7 +178,7 @@ fun case_9(x: TypealiasNullableString?) { fun case_10() { val a = Class() - if (a.prop_4 === null || a.prop_4 === null || true) { + if (a.prop_4 === null || a.prop_4 === null || true) { if (a.prop_4 != null) { a.prop_4 a.prop_4.equals(null) @@ -300,7 +300,7 @@ fun case_16() { } // TESTCASE NUMBER: 17 -val case_17 = if (nullableIntProperty == null || nullableNothingProperty === nullableIntProperty) 0 else { +val case_17 = if (nullableIntProperty == null || nullableNothingProperty === nullableIntProperty) 0 else { nullableIntProperty.equals(null) nullableIntProperty.propT nullableIntProperty.propAny @@ -398,7 +398,7 @@ fun case_20(b: Boolean) { // TESTCASE NUMBER: 21 fun case_21() { val y = null - if (EnumClassWithNullableProperty.A.prop_1 !== null && y != EnumClassWithNullableProperty.A.prop_1) { + if (EnumClassWithNullableProperty.A.prop_1 !== null && y != EnumClassWithNullableProperty.A.prop_1) { EnumClassWithNullableProperty.A.prop_1 EnumClassWithNullableProperty.A.prop_1.equals(null) EnumClassWithNullableProperty.A.prop_1.propT @@ -431,9 +431,9 @@ fun case_22(a: (() -> Unit)?) { // TESTCASE NUMBER: 23 fun case_23(a: ((Float) -> Int?)?, b: Float?, c: Nothing?) { - if (a != null && b !== null || a != c && b !== c) { + if (a != null && b !== null || a != c && b !== c) { val x = a(b) - if (x != null || c !== x) { + if (x != null || c !== x) { x x.equals(null) x.propT @@ -543,7 +543,7 @@ fun case_27(y: Nothing?) { //TESTCASE NUMBER: 28 fun case_28(a: DeepObject.A.B.C.D.E.F.G.J?) = - if (a != null == true == false == false == false == true == false == true == false == false == true == true && a.x !== nullableNothingProperty) { + if (a != null == true == false == false == false == true == false == true == false == false == true == true && a.x !== nullableNothingProperty) { a.x a.equals(null) a.propT @@ -557,13 +557,13 @@ fun case_28(a: DeepObject.A.B.C.D.E.F.G.J?) = } else -1 // TESTCASE NUMBER: 29 -fun case_29(a: Int?, b: Nothing?, c: Int = if (a === b) 0 else a) { +fun case_29(a: Int?, b: Nothing?, c: Int = if (a === b) 0 else a) { a b } // TESTCASE NUMBER: 30 -fun case_30(a: Int?, b: Nothing?, c: Int = if (a === b || a == null) 0 else a) { +fun case_30(a: Int?, b: Nothing?, c: Int = if (a === b || a == null) 0 else a) { a b }