mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user