mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[AST] Remove GenericSignature params from GenericEnvironment methods.
The GenericEnvironment stores a signature internally.
This commit is contained in:
@@ -83,18 +83,16 @@ public:
|
||||
/// with contextual types instead of interface types.
|
||||
SubstitutionMap
|
||||
getSubstitutionMap(ModuleDecl *mod,
|
||||
GenericSignature *sig,
|
||||
ArrayRef<Substitution> subs) const;
|
||||
|
||||
/// Same as above, but updates an existing map.
|
||||
void
|
||||
getSubstitutionMap(ModuleDecl *mod,
|
||||
GenericSignature *sig,
|
||||
ArrayRef<Substitution> subs,
|
||||
SubstitutionMap &subMap) const;
|
||||
|
||||
ArrayRef<Substitution>
|
||||
getForwardingSubstitutions(ModuleDecl *M, GenericSignature *sig) const;
|
||||
getForwardingSubstitutions(ModuleDecl *M) const;
|
||||
|
||||
void dump() const;
|
||||
};
|
||||
|
||||
@@ -41,8 +41,7 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
|
||||
|
||||
void computeSubsMap() {
|
||||
if (auto *env = Original.getGenericEnvironment()) {
|
||||
auto sig = Original.getLoweredFunctionType()->getGenericSignature();
|
||||
SubsMap = env->getSubstitutionMap(SwiftMod, sig, ApplySubs);
|
||||
SubsMap = env->getSubstitutionMap(SwiftMod, ApplySubs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,8 +89,7 @@ GenericTypeParamType *GenericEnvironment::getSugaredType(
|
||||
}
|
||||
|
||||
ArrayRef<Substitution>
|
||||
GenericEnvironment::getForwardingSubstitutions(
|
||||
ModuleDecl *M, GenericSignature *sig) const {
|
||||
GenericEnvironment::getForwardingSubstitutions(ModuleDecl *M) const {
|
||||
auto lookupConformanceFn =
|
||||
[&](CanType original, Type replacement, ProtocolType *protoType)
|
||||
-> ProtocolConformanceRef {
|
||||
@@ -105,16 +104,14 @@ GenericEnvironment::getForwardingSubstitutions(
|
||||
|
||||
SubstitutionMap GenericEnvironment::
|
||||
getSubstitutionMap(ModuleDecl *mod,
|
||||
GenericSignature *sig,
|
||||
ArrayRef<Substitution> subs) const {
|
||||
SubstitutionMap result;
|
||||
getSubstitutionMap(mod, getGenericSignature(), subs, result);
|
||||
getSubstitutionMap(mod, subs, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void GenericEnvironment::
|
||||
getSubstitutionMap(ModuleDecl *mod,
|
||||
GenericSignature *sig,
|
||||
ArrayRef<Substitution> subs,
|
||||
SubstitutionMap &result) const {
|
||||
for (auto depTy : getGenericSignature()->getAllDependentTypes()) {
|
||||
|
||||
@@ -379,10 +379,9 @@ SpecializedProtocolConformance::getTypeWitnessSubstAndDecl(
|
||||
auto conformingModule = conformingDC->getParentModule();
|
||||
|
||||
auto *genericEnv = GenericConformance->getGenericEnvironment();
|
||||
auto *genericSig = GenericConformance->getGenericSignature();
|
||||
|
||||
auto substitutionMap = genericEnv->getSubstitutionMap(
|
||||
conformingModule, genericSig, GenericSubstitutions);
|
||||
conformingModule, GenericSubstitutions);
|
||||
|
||||
auto genericWitnessAndDecl
|
||||
= GenericConformance->getTypeWitnessSubstAndDecl(assocType, resolver);
|
||||
@@ -534,10 +533,9 @@ ProtocolConformance::getInheritedConformance(ProtocolDecl *protocol) const {
|
||||
auto *conformingDC = spec->getDeclContext();
|
||||
auto *conformingModule = conformingDC->getParentModule();
|
||||
|
||||
auto *sig = conformingDC->getGenericSignatureOfContext();
|
||||
auto *env = conformingDC->getGenericEnvironmentOfContext();
|
||||
|
||||
auto subMap = env->getSubstitutionMap(conformingModule, sig, subs);
|
||||
auto subMap = env->getSubstitutionMap(conformingModule, subs);
|
||||
|
||||
auto r = inherited->subst(conformingModule, getType(), subMap);
|
||||
assert(getType()->isEqual(r->getType())
|
||||
|
||||
@@ -547,9 +547,8 @@ ArrayRef<Substitution> SILFunction::getForwardingSubstitutions() {
|
||||
if (!env)
|
||||
return {};
|
||||
|
||||
auto sig = getLoweredFunctionType()->getGenericSignature();
|
||||
auto *M = getModule().getSwiftModule();
|
||||
ForwardingSubs = env->getForwardingSubstitutions(M, sig);
|
||||
ForwardingSubs = env->getForwardingSubstitutions(M);
|
||||
|
||||
return *ForwardingSubs;
|
||||
}
|
||||
|
||||
@@ -1964,8 +1964,7 @@ public:
|
||||
|
||||
// Map interface types to archetypes.
|
||||
if (auto *env = constantInfo.GenericEnv) {
|
||||
auto sig = constantInfo.SILFnType->getGenericSignature();
|
||||
auto subs = env->getForwardingSubstitutions(M, sig);
|
||||
auto subs = env->getForwardingSubstitutions(M);
|
||||
methodTy = methodTy->substGenericArgs(F.getModule(), M, subs);
|
||||
}
|
||||
assert(!methodTy->isPolymorphic());
|
||||
|
||||
@@ -78,11 +78,9 @@ emitBridgeNativeToObjectiveC(SILGenFunction &gen,
|
||||
// FIXME: Substitute the type substitutions into the witness, because
|
||||
// SpecializedProtocolConformance::getWitness() doesn't do it for us.
|
||||
GenericEnvironment *witnessEnv = witness.getSyntheticEnvironment();
|
||||
GenericSignature *witnessSig = witness.getSyntheticSignature();
|
||||
|
||||
|
||||
SubstitutionMap typeSubMap = witnessEnv
|
||||
->getSubstitutionMap(gen.SGM.SwiftModule,
|
||||
witnessSig,
|
||||
typeSubstitutions);
|
||||
for (auto sub : witnessSubstitutions) {
|
||||
substitutionsBuf.push_back(sub.subst(gen.SGM.SwiftModule, typeSubMap));
|
||||
|
||||
@@ -490,9 +490,8 @@ void SILGenFunction::emitClassConstructorAllocator(ConstructorDecl *ctor) {
|
||||
// Call the initializer.
|
||||
ArrayRef<Substitution> forwardingSubs;
|
||||
if (auto *genericEnv = ctor->getGenericEnvironmentOfContext()) {
|
||||
auto *genericSig = ctor->getGenericSignatureOfContext();
|
||||
forwardingSubs = genericEnv->getForwardingSubstitutions(
|
||||
SGM.SwiftModule, genericSig);
|
||||
SGM.SwiftModule);
|
||||
}
|
||||
std::tie(initVal, initTy, subs)
|
||||
= emitSiblingMethodRef(Loc, selfValue, initConstant, forwardingSubs);
|
||||
@@ -882,9 +881,8 @@ void SILGenFunction::emitMemberInitializers(DeclContext *dc,
|
||||
ArrayRef<Substitution> subs;
|
||||
auto *genericEnv = dc->getGenericEnvironmentOfContext();
|
||||
if (genericEnv) {
|
||||
auto *genericSig = dc->getGenericSignatureOfContext();
|
||||
subs = genericEnv->getForwardingSubstitutions(
|
||||
SGM.SwiftModule, genericSig);
|
||||
SGM.SwiftModule);
|
||||
}
|
||||
|
||||
// Get the type of the initialization result, in terms
|
||||
|
||||
@@ -815,8 +815,7 @@ void SILGenFunction::emitCurryThunk(ValueDecl *vd,
|
||||
ArrayRef<Substitution> subs;
|
||||
auto constantInfo = getConstantInfo(to);
|
||||
if (auto *env = constantInfo.GenericEnv) {
|
||||
auto sig = constantInfo.SILFnType->getGenericSignature();
|
||||
subs = env->getForwardingSubstitutions(SGM.SwiftModule, sig);
|
||||
subs = env->getForwardingSubstitutions(SGM.SwiftModule);
|
||||
}
|
||||
|
||||
SILValue toFn = getNextUncurryLevelRef(*this, vd, to, from.isDirectReference,
|
||||
|
||||
@@ -1582,9 +1582,8 @@ SILGenModule::getNonMemberVarDeclSubstitutions(VarDecl *var) {
|
||||
ArrayRef<Substitution> substitutions;
|
||||
auto *dc = var->getDeclContext();
|
||||
if (auto *genericEnv = dc->getGenericEnvironmentOfContext()) {
|
||||
auto *genericSig = dc->getGenericSignatureOfContext();
|
||||
substitutions = genericEnv->getForwardingSubstitutions(
|
||||
SwiftModule, genericSig);
|
||||
SwiftModule);
|
||||
}
|
||||
return substitutions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user