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