mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Constraint solver] Unify the two typeVarOccursInType implementations.
NFC, thanks @CodaFi!
This commit is contained in:
@@ -77,6 +77,29 @@ void ConstraintSystem::mergeEquivalenceClasses(TypeVariableType *typeVar1,
|
||||
}
|
||||
}
|
||||
|
||||
/// Determine whether the given type variables occurs in the given type.
|
||||
bool ConstraintSystem::typeVarOccursInType(TypeVariableType *typeVar,
|
||||
Type type,
|
||||
bool *involvesOtherTypeVariables) {
|
||||
SmallVector<TypeVariableType *, 4> typeVars;
|
||||
type->getTypeVariables(typeVars);
|
||||
bool result = false;
|
||||
for (auto referencedTypeVar : typeVars) {
|
||||
if (referencedTypeVar == typeVar) {
|
||||
result = true;
|
||||
if (!involvesOtherTypeVariables || *involvesOtherTypeVariables)
|
||||
break;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (involvesOtherTypeVariables)
|
||||
*involvesOtherTypeVariables = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void ConstraintSystem::assignFixedType(TypeVariableType *typeVar, Type type,
|
||||
bool updateState) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user