[NI] Fix coercion to Unit for explicitly specified type argument
#KT-25424 Fixed
This commit is contained in:
+2
-2
@@ -25,7 +25,7 @@ class PostponedArgumentsAnalyzer(
|
||||
// type can be proper if it not contains not fixed type variables
|
||||
fun canBeProper(type: UnwrappedType): Boolean
|
||||
|
||||
fun hasUpperUnitConstraint(type: UnwrappedType): Boolean
|
||||
fun hasUpperOrEqualUnitConstraint(type: UnwrappedType): Boolean
|
||||
|
||||
// mutable operations
|
||||
fun addOtherSystem(otherSystem: ConstraintStorage)
|
||||
@@ -76,7 +76,7 @@ class PostponedArgumentsAnalyzer(
|
||||
c.canBeProper(rawReturnType) -> substitute(rawReturnType)
|
||||
|
||||
// For Unit-coercion
|
||||
c.hasUpperUnitConstraint(rawReturnType) -> lambda.returnType.builtIns.unitType
|
||||
c.hasUpperOrEqualUnitConstraint(rawReturnType) -> lambda.returnType.builtIns.unitType
|
||||
|
||||
else -> null
|
||||
}
|
||||
|
||||
+2
-2
@@ -289,11 +289,11 @@ class NewConstraintSystemImpl(
|
||||
}
|
||||
|
||||
// PostponedArgumentsAnalyzer.Context
|
||||
override fun hasUpperUnitConstraint(type: UnwrappedType): Boolean {
|
||||
override fun hasUpperOrEqualUnitConstraint(type: UnwrappedType): Boolean {
|
||||
checkState(State.BUILDING, State.COMPLETION, State.FREEZED)
|
||||
|
||||
val constraints = storage.notFixedTypeVariables[type.constructor]?.constraints ?: return false
|
||||
|
||||
return constraints.any { it.kind == ConstraintKind.UPPER && it.type.isUnit() }
|
||||
return constraints.any { (it.kind == ConstraintKind.UPPER || it.kind == ConstraintKind.EQUALITY) && it.type.isUnit() }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user