diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java index ce8c11576ba..04627edf4e6 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java @@ -10808,6 +10808,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte runTest("compiler/testData/diagnostics/tests/inference/nothingType/nestedLambdaInferenceWithIncorporationOfVariables.kt"); } + @TestMetadata("notEnoughInformationFromNullabilityConstraint.kt") + public void testNotEnoughInformationFromNullabilityConstraint() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationFromNullabilityConstraint.kt"); + } + @TestMetadata("nothingWithCallableReference.kt") public void testNothingWithCallableReference() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/nothingType/nothingWithCallableReference.kt"); diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt index a90550d8a01..1a30b1cb4c2 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt @@ -131,7 +131,9 @@ class VariableFixationFinder( notFixedTypeVariables[variable]?.constraints?.any { isProperArgumentConstraint(it) } ?: false private fun Context.isProperArgumentConstraint(c: Constraint) = - isProperType(c.type) && c.position.initialConstraint.position !is DeclaredUpperBoundConstraintPosition + isProperType(c.type) + && c.position.initialConstraint.position !is DeclaredUpperBoundConstraintPosition + && !c.isNullabilityConstraint private fun Context.isProperType(type: KotlinTypeMarker): Boolean = !type.contains { notFixedTypeVariables.containsKey(it.typeConstructor()) } diff --git a/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationFromNullabilityConstraint.fir.kt b/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationFromNullabilityConstraint.fir.kt new file mode 100644 index 00000000000..d94e0698397 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationFromNullabilityConstraint.fir.kt @@ -0,0 +1,9 @@ +// !LANGUAGE: +NewInference +// !WITH_NEW_INFERENCE + +fun make(): M? = null +fun id(arg: I): I = arg + +val v = id( + make() +) diff --git a/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationFromNullabilityConstraint.kt b/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationFromNullabilityConstraint.kt new file mode 100644 index 00000000000..941922ee636 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationFromNullabilityConstraint.kt @@ -0,0 +1,9 @@ +// !LANGUAGE: +NewInference +// !WITH_NEW_INFERENCE + +fun make(): M? = null +fun id(arg: I): I = arg + +val v = id( + make() +) diff --git a/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationFromNullabilityConstraint.txt b/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationFromNullabilityConstraint.txt new file mode 100644 index 00000000000..ebe772bedaf --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationFromNullabilityConstraint.txt @@ -0,0 +1,7 @@ +package + +public val v: [ERROR : Type for id( + make() +)] +public fun id(/*0*/ arg: I): I +public fun make(): M? diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 2d01b9801b0..6381c5eeda8 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -10815,6 +10815,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/inference/nothingType/nestedLambdaInferenceWithIncorporationOfVariables.kt"); } + @TestMetadata("notEnoughInformationFromNullabilityConstraint.kt") + public void testNotEnoughInformationFromNullabilityConstraint() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationFromNullabilityConstraint.kt"); + } + @TestMetadata("nothingWithCallableReference.kt") public void testNothingWithCallableReference() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/nothingType/nothingWithCallableReference.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 6702cd25d43..ead08c2f4c0 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -10810,6 +10810,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/inference/nothingType/nestedLambdaInferenceWithIncorporationOfVariables.kt"); } + @TestMetadata("notEnoughInformationFromNullabilityConstraint.kt") + public void testNotEnoughInformationFromNullabilityConstraint() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationFromNullabilityConstraint.kt"); + } + @TestMetadata("nothingWithCallableReference.kt") public void testNothingWithCallableReference() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/nothingType/nothingWithCallableReference.kt");