Move mutating methods of ConstraintSystem to Builder

Extract immutable ConstraintSystemSnapshot from ConstraintSystemImpl
This commit is contained in:
Alexander Udalov
2015-10-29 19:42:19 +03:00
parent d320922e08
commit bb918a2742
11 changed files with 323 additions and 238 deletions
@@ -116,16 +116,18 @@ class FuzzyType(
return if (type.checkInheritance(otherType.type)) TypeSubstitutor.EMPTY else null
}
val constraintSystem = ConstraintSystemImpl()
constraintSystem.registerTypeVariables(freeParameters)
constraintSystem.registerTypeVariables(otherType.freeParameters)
val builder = ConstraintSystemImpl()
builder.registerTypeVariables(freeParameters)
builder.registerTypeVariables(otherType.freeParameters)
when (matchKind) {
MatchKind.IS_SUBTYPE -> constraintSystem.addSubtypeConstraint(type, otherType.type, ConstraintPositionKind.RECEIVER_POSITION.position())
MatchKind.IS_SUPERTYPE -> constraintSystem.addSubtypeConstraint(otherType.type, type, ConstraintPositionKind.RECEIVER_POSITION.position())
MatchKind.IS_SUBTYPE -> builder.addSubtypeConstraint(type, otherType.type, ConstraintPositionKind.RECEIVER_POSITION.position())
MatchKind.IS_SUPERTYPE -> builder.addSubtypeConstraint(otherType.type, type, ConstraintPositionKind.RECEIVER_POSITION.position())
}
constraintSystem.fixVariables()
builder.fixVariables()
val constraintSystem = builder.build()
if (constraintSystem.getStatus().hasContradiction()) return null