Introduce TypeBase::isTypeVariableOrMember(). NFC

Similar to “isTypeParameter,” this new entry point determines whether the type is a type variable or a nested type of a type thereof. The latter case isn’t actually formed yet, so this is NFC staging the trivial bits of this change.
This commit is contained in:
Doug Gregor
2016-10-11 09:23:15 -07:00
parent f38029bae5
commit ab959c9f21
6 changed files with 34 additions and 7 deletions

View File

@@ -630,7 +630,8 @@ TypeBase::gatherAllSubstitutions(Module *module,
// If the type is a type variable or is dependent, just fill in empty
// conformances.
if (replacement->is<TypeVariableType>() || replacement->isTypeParameter())
if (replacement->isTypeVariableOrMember() ||
replacement->isTypeParameter())
return ProtocolConformanceRef(proto);
// Otherwise, find the conformance.
@@ -743,6 +744,11 @@ Module::lookupConformance(Type type, ProtocolDecl *protocol,
return None;
}
// Type variables have trivial conformances.
if (type->isTypeVariableOrMember()) {
return ProtocolConformanceRef(protocol);
}
// UnresolvedType is a placeholder for an unknown type used when generating
// diagnostics. We consider it to conform to all protocols, since the
// intended type might have.