diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt index 91bb087104c..3583da575f2 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt @@ -70,7 +70,7 @@ class VariableFixationFinder( isReified(variable) -> TypeVariableFixationReadiness.READY_FOR_FIXATION_REIFIED inferenceCompatibilityModeEnabled -> { when { - variableHasLowerProperConstraint(variable) -> TypeVariableFixationReadiness.READY_FOR_FIXATION_LOWER + variableHasLowerNonNothingProperConstraint(variable) -> TypeVariableFixationReadiness.READY_FOR_FIXATION_LOWER else -> TypeVariableFixationReadiness.READY_FOR_FIXATION_UPPER } } @@ -159,12 +159,13 @@ class VariableFixationFinder( private fun Context.isReified(variable: TypeConstructorMarker): Boolean = notFixedTypeVariables[variable]?.typeVariable?.let { isReified(it) } ?: false - private fun Context.variableHasLowerProperConstraint(variable: TypeConstructorMarker): Boolean = - notFixedTypeVariables[variable]?.constraints?.let { constraints -> - constraints.any { - it.kind.isLower() && isProperArgumentConstraint(it) - } - } ?: false + private fun Context.variableHasLowerNonNothingProperConstraint(variable: TypeConstructorMarker): Boolean { + val constraints = notFixedTypeVariables[variable]?.constraints ?: return false + + return constraints.any { + it.kind.isLower() && isProperArgumentConstraint(it) && !it.type.typeConstructor().isNothingConstructor() + } + } } inline fun TypeSystemInferenceExtensionContext.isProperTypeForFixation( diff --git a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt index 1c4ce614a63..8924f9b4924 100644 --- a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt +++ b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt @@ -10,5 +10,5 @@ fun Some.doWithPredicate(predicate: (R) -> Unit): R? = TODO() fun test(derived: Some) { val expected: Some = derived.doWithPredicate { it.method() } ?: TODO() - val expected2: Some = elvis(derived.doWithPredicate { it.method() }, TODO()) + val expected2: Some = elvis(derived.doWithPredicate { it.method() }, TODO()) }