diff --git a/compiler/fir/resolve/testData/resolve/problems/flexibleTypeVarAgainstNull.kt b/compiler/fir/resolve/testData/resolve/problems/flexibleTypeVarAgainstNull.kt new file mode 100644 index 00000000000..37b6a1c3d6b --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/flexibleTypeVarAgainstNull.kt @@ -0,0 +1,16 @@ +// FILE: JavaClass.java +public class JavaClass { + public JavaClass(T t) {} + + public T foo() {} +} + +// FILE: main.kt +fun main() { + // See https://github.com/JetBrains/kotlin/commit/437a26684d3529ee2cfdbe54e59d50f4a6f0a611#diff-ba68311bbe28b71196c36a6246000382L176 + // In simplifyLowerConstraint, we add constraint Nothing? <: T!, approximating it with Nothing? <: T + // But before it we already had T <: String from the explicit types + // That lead us to constraint contradiction: Nothing? !<: String + // We need to discuss the commit above at some point + JavaClass(null).foo().length +} diff --git a/compiler/fir/resolve/testData/resolve/problems/flexibleTypeVarAgainstNull.txt b/compiler/fir/resolve/testData/resolve/problems/flexibleTypeVarAgainstNull.txt new file mode 100644 index 00000000000..b7ae6a0886d --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/flexibleTypeVarAgainstNull.txt @@ -0,0 +1,4 @@ +FILE: main.kt + public final fun main(): R|kotlin/Unit| { + #(Null(null)).#().# + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index a97df7ab7b8..1587f1f2e2a 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -1407,6 +1407,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/resolve/testData/resolve/problems/definitelyNotNullAndOriginalType.kt"); } + @TestMetadata("flexibleTypeVarAgainstNull.kt") + public void testFlexibleTypeVarAgainstNull() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/problems/flexibleTypeVarAgainstNull.kt"); + } + @TestMetadata("javaAccessorConversion.kt") public void testJavaAccessorConversion() throws Exception { runTest("compiler/fir/resolve/testData/resolve/problems/javaAccessorConversion.kt"); diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index c9106726fb0..155aae3db6a 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -1407,6 +1407,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/resolve/testData/resolve/problems/definitelyNotNullAndOriginalType.kt"); } + @TestMetadata("flexibleTypeVarAgainstNull.kt") + public void testFlexibleTypeVarAgainstNull() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/problems/flexibleTypeVarAgainstNull.kt"); + } + @TestMetadata("javaAccessorConversion.kt") public void testJavaAccessorConversion() throws Exception { runTest("compiler/fir/resolve/testData/resolve/problems/javaAccessorConversion.kt");