From 3987efa036272f9d81c9af1e4934c3707f10a345 Mon Sep 17 00:00:00 2001 From: Nikolay Lunyak Date: Tue, 4 Apr 2023 15:15:43 +0300 Subject: [PATCH] [FIR] Remove the fast path `if` as insignificant This if is a bit inconsistent with the LUB checking approach, so if it doesn't improve performance it's better to remove it. --- .../intellij/IntersectionWithJavaString.kt | 2 +- .../expression/FirEqualityCompatibilityChecker.kt | 8 +++----- .../diagnostics/tests/BinaryCallsOnNullableValues.fir.kt | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/IntersectionWithJavaString.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/IntersectionWithJavaString.kt index 3fd79de9e88..907f337296e 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/IntersectionWithJavaString.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/IntersectionWithJavaString.kt @@ -5,5 +5,5 @@ fun collapse(path: String) { val result = (path as java.lang.String).replace("123", "456") - if (result !== path) {} + if (result !== path) {} } 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 672272ee1a5..87f822833ce 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 @@ -121,14 +121,12 @@ object FirEqualityCompatibilityChecker : FirEqualityOperatorCallChecker() { // we only need to check if one is related // to the other - fun TypeInfo.isSubclassOf(other: TypeInfo) = when { - other.enforcesEmptyIntersection -> type.classId == other.type.classId - else -> notNullType.isSubtypeOf(other.notNullType, context.session) - } + fun TypeInfo.isSubtypeOf(other: TypeInfo) = + notNullType.isSubtypeOf(other.notNullType, context.session) return when { l.type.isNothingOrNullableNothing || r.type.isNothingOrNullableNothing -> false - else -> !l.isSubclassOf(r) && !r.isSubclassOf(l) + else -> !l.isSubtypeOf(r) && !r.isSubtypeOf(l) } } diff --git a/compiler/testData/diagnostics/tests/BinaryCallsOnNullableValues.fir.kt b/compiler/testData/diagnostics/tests/BinaryCallsOnNullableValues.fir.kt index 76c71e08a72..02449200689 100644 --- a/compiler/testData/diagnostics/tests/BinaryCallsOnNullableValues.fir.kt +++ b/compiler/testData/diagnostics/tests/BinaryCallsOnNullableValues.fir.kt @@ -10,8 +10,8 @@ fun f(): Unit { x < 1 x += 1 - x == 1 - x != 1 + x == 1 + x != 1 A() == 1