[Constraint solver] Use the type representative in the "occurs" check.

When performing the occurs check, look for the *representative* of the
type variable we're about to bind, rather than the type variable
itself. Fixes rdar://problem/26845038, SR-1512, SR-1902, SR2635,
SR-2852, and SR-2766.
This commit is contained in:
Doug Gregor
2016-10-25 22:22:36 -07:00
parent d49a246063
commit b295106830
8 changed files with 160 additions and 13 deletions

View File

@@ -103,14 +103,6 @@ bool ConstraintSystem::typeVarOccursInType(TypeVariableType *typeVar,
void ConstraintSystem::assignFixedType(TypeVariableType *typeVar, Type type,
bool updateState) {
// If the type to be fixed is an optional type that wraps the type parameter
// itself, we do not want to go through with the assignment. To do so would
// force the type variable to be adjacent to itself.
if (auto optValueType = type->getOptionalObjectType()) {
if (optValueType->isEqual(typeVar))
return;
}
typeVar->getImpl().assignFixedType(type, getSavedBindings());
if (!updateState)