Lift Requirement and Parameter Accessors up to GenericSignature

Start treating the null {Can}GenericSignature as a regular signature
with no requirements and no parameters. This not only makes for a much
safer abstraction, but allows us to simplify a lot of the clients of
GenericSignature that would previously have to check for null before
using the abstraction.
This commit is contained in:
Robert Widmann
2021-07-14 19:05:28 -07:00
parent 9a1d18ae4f
commit d86551de67
61 changed files with 283 additions and 247 deletions

View File

@@ -1407,7 +1407,7 @@ static void bindArchetypesFromContext(
if (!genericSig)
break;
for (auto *paramTy : genericSig->getGenericParams()) {
for (auto *paramTy : genericSig.getGenericParams()) {
Type contextTy = cs.DC->mapTypeIntoContext(paramTy);
bindPrimaryArchetype(paramTy, contextTy);
}
@@ -1439,7 +1439,7 @@ void ConstraintSystem::openGenericParameters(DeclContext *outerDC,
assert(sig);
// Create the type variables for the generic parameters.
for (auto gp : sig->getGenericParams()) {
for (auto gp : sig.getGenericParams()) {
auto *paramLocator = getConstraintLocator(
locator.withPathElement(LocatorPathElt::GenericParameter(gp)));
@@ -1462,7 +1462,7 @@ void ConstraintSystem::openGenericRequirements(
DeclContext *outerDC, GenericSignature signature,
bool skipProtocolSelfConstraint, ConstraintLocatorBuilder locator,
llvm::function_ref<Type(Type)> substFn) {
auto requirements = signature->getRequirements();
auto requirements = signature.getRequirements();
for (unsigned pos = 0, n = requirements.size(); pos != n; ++pos) {
const auto &req = requirements[pos];
@@ -5588,7 +5588,7 @@ static Optional<Requirement> getRequirement(ConstraintSystem &cs,
if (auto openedGeneric =
reqLocator->findLast<LocatorPathElt::OpenedGeneric>()) {
auto signature = openedGeneric->getSignature();
return signature->getRequirements()[reqLoc->getIndex()];
return signature.getRequirements()[reqLoc->getIndex()];
}
return None;