Don't fix type variables into Nothing in priority way
^KT-44546 Fixed
This commit is contained in:
+8
-7
@@ -70,7 +70,7 @@ class VariableFixationFinder(
|
|||||||
isReified(variable) -> TypeVariableFixationReadiness.READY_FOR_FIXATION_REIFIED
|
isReified(variable) -> TypeVariableFixationReadiness.READY_FOR_FIXATION_REIFIED
|
||||||
inferenceCompatibilityModeEnabled -> {
|
inferenceCompatibilityModeEnabled -> {
|
||||||
when {
|
when {
|
||||||
variableHasLowerProperConstraint(variable) -> TypeVariableFixationReadiness.READY_FOR_FIXATION_LOWER
|
variableHasLowerNonNothingProperConstraint(variable) -> TypeVariableFixationReadiness.READY_FOR_FIXATION_LOWER
|
||||||
else -> TypeVariableFixationReadiness.READY_FOR_FIXATION_UPPER
|
else -> TypeVariableFixationReadiness.READY_FOR_FIXATION_UPPER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,12 +159,13 @@ class VariableFixationFinder(
|
|||||||
private fun Context.isReified(variable: TypeConstructorMarker): Boolean =
|
private fun Context.isReified(variable: TypeConstructorMarker): Boolean =
|
||||||
notFixedTypeVariables[variable]?.typeVariable?.let { isReified(it) } ?: false
|
notFixedTypeVariables[variable]?.typeVariable?.let { isReified(it) } ?: false
|
||||||
|
|
||||||
private fun Context.variableHasLowerProperConstraint(variable: TypeConstructorMarker): Boolean =
|
private fun Context.variableHasLowerNonNothingProperConstraint(variable: TypeConstructorMarker): Boolean {
|
||||||
notFixedTypeVariables[variable]?.constraints?.let { constraints ->
|
val constraints = notFixedTypeVariables[variable]?.constraints ?: return false
|
||||||
constraints.any {
|
|
||||||
it.kind.isLower() && isProperArgumentConstraint(it)
|
return constraints.any {
|
||||||
}
|
it.kind.isLower() && isProperArgumentConstraint(it) && !it.type.typeConstructor().isNothingConstructor()
|
||||||
} ?: false
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun TypeSystemInferenceExtensionContext.isProperTypeForFixation(
|
inline fun TypeSystemInferenceExtensionContext.isProperTypeForFixation(
|
||||||
|
|||||||
+1
-1
@@ -10,5 +10,5 @@ fun <R : Some> Some.doWithPredicate(predicate: (R) -> Unit): R? = TODO()
|
|||||||
|
|
||||||
fun test(derived: Some) {
|
fun test(derived: Some) {
|
||||||
val expected: Some = derived.doWithPredicate { it.method() } ?: TODO()
|
val expected: Some = derived.doWithPredicate { it.method() } ?: TODO()
|
||||||
val expected2: Some = <!IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION!>elvis<!>(derived.doWithPredicate { it.<!UNRESOLVED_REFERENCE!>method<!>() }, TODO())
|
val expected2: Some = elvis(derived.doWithPredicate { it.method() }, TODO())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user