Always alpha-convert non-external type parameters before registering in system

This commit is contained in:
Alexander Udalov
2015-11-06 19:01:42 +03:00
parent 4d5d24a503
commit 27ce61a3be
6 changed files with 47 additions and 47 deletions
@@ -115,12 +115,19 @@ class FuzzyType(
}
val builder = ConstraintSystemBuilderImpl()
builder.registerTypeVariables(freeParameters)
builder.registerTypeVariables(otherType.freeParameters)
val typeVariableSubstitutor = builder.registerTypeVariables(freeParameters + otherType.freeParameters)
when (matchKind) {
MatchKind.IS_SUBTYPE -> builder.addSubtypeConstraint(type, otherType.type, ConstraintPositionKind.RECEIVER_POSITION.position())
MatchKind.IS_SUPERTYPE -> builder.addSubtypeConstraint(otherType.type, type, ConstraintPositionKind.RECEIVER_POSITION.position())
MatchKind.IS_SUBTYPE -> builder.addSubtypeConstraint(
typeVariableSubstitutor.substitute(type, Variance.INVARIANT),
otherType.type,
ConstraintPositionKind.RECEIVER_POSITION.position()
)
MatchKind.IS_SUPERTYPE -> builder.addSubtypeConstraint(
typeVariableSubstitutor.substitute(otherType.type, Variance.INVARIANT),
type,
ConstraintPositionKind.RECEIVER_POSITION.position()
)
}
builder.fixVariables()