Skip to content

Commit 049c56d

Browse files
committed
Eliminate getForwardingSubstitutions().
Use the SubstitutionMap version everywhere.
1 parent cb3bf10 commit 049c56d

File tree

10 files changed

+5
-44
lines changed

10 files changed

+5
-44
lines changed

include/swift/AST/GenericEnvironment.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
171171
Type getSugaredType(Type type) const;
172172

173173
SubstitutionMap getForwardingSubstitutionMap() const;
174-
SubstitutionList getForwardingSubstitutions() const;
175174

176175
void dump(raw_ostream &os) const;
177176

include/swift/SIL/SILFunction.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ class SILFunction
121121
/// Only set if this function is a specialization of another function.
122122
const GenericSpecializationInformation *SpecializationInfo;
123123

124-
/// The forwarding substitutions, lazily computed.
125-
Optional<SubstitutionList> ForwardingSubs;
126-
127124
/// The forwarding substitution map, lazily computed.
128125
SubstitutionMap ForwardingSubMap;
129126

@@ -684,10 +681,6 @@ class SILFunction
684681
/// Converts the given function definition to a declaration.
685682
void convertToDeclaration();
686683

687-
/// Return the identity substitutions necessary to forward this call if it is
688-
/// generic.
689-
SubstitutionList getForwardingSubstitutions();
690-
691684
/// Return the identity substitutions necessary to forward this call if it is
692685
/// generic.
693686
SubstitutionMap getForwardingSubstitutionMap();

lib/AST/GenericEnvironment.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,6 @@ SubstitutionMap GenericEnvironment::getForwardingSubstitutionMap() const {
225225
MakeAbstractConformanceForGenericType());
226226
}
227227

228-
SubstitutionList
229-
GenericEnvironment::getForwardingSubstitutions() const {
230-
auto *genericSig = getGenericSignature();
231-
232-
SmallVector<Substitution, 4> result;
233-
genericSig->getSubstitutions(getForwardingSubstitutionMap(), result);
234-
return genericSig->getASTContext().AllocateCopy(result);
235-
}
236-
237228
std::pair<Type, ProtocolConformanceRef>
238229
GenericEnvironment::mapConformanceRefIntoContext(GenericEnvironment *genericEnv,
239230
Type conformingType,

lib/IRGen/GenKeyPath.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ getAccessorForComputedComponent(IRGenModule &IGM,
230230
// Use the bound generic metadata to form a call to the original generic
231231
// accessor.
232232
WitnessMetadata ignoreWitnessMetadata;
233-
auto forwardingSubs = genericEnv->getGenericSignature()->getSubstitutionMap(
234-
genericEnv->getForwardingSubstitutions());
233+
auto forwardingSubs = genericEnv->getForwardingSubstitutionMap();
235234
emitPolymorphicArguments(IGF, accessor->getLoweredFunctionType(),
236235
forwardingSubs,
237236
&ignoreWitnessMetadata,

lib/SIL/SILFunction.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -482,18 +482,6 @@ void SILFunction::convertToDeclaration() {
482482
getBlocks().clear();
483483
}
484484

485-
SubstitutionList SILFunction::getForwardingSubstitutions() {
486-
if (ForwardingSubs)
487-
return *ForwardingSubs;
488-
489-
auto *env = getGenericEnvironment();
490-
if (!env)
491-
return {};
492-
493-
ForwardingSubs = env->getForwardingSubstitutions();
494-
return *ForwardingSubs;
495-
}
496-
497485
SubstitutionMap SILFunction::getForwardingSubstitutionMap() {
498486
if (ForwardingSubMap)
499487
return ForwardingSubMap;

lib/SIL/SILVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
24402440

24412441
// Map interface types to archetypes.
24422442
if (auto *env = constantInfo.GenericEnv) {
2443-
auto subs = env->getForwardingSubstitutions();
2443+
auto subs = env->getForwardingSubstitutionMap();
24442444
methodTy = methodTy->substGenericArgs(F.getModule(), subs);
24452445
}
24462446
assert(!methodTy->isPolymorphic());

lib/SILGen/SILGenDecl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ namespace {
144144
};
145145
} // end anonymous namespace
146146

147-
SubstitutionList SILGenFunction::getForwardingSubstitutions() {
148-
return F.getForwardingSubstitutions();
149-
}
150-
151147
SubstitutionMap SILGenFunction::getForwardingSubstitutionMap() {
152148
return F.getForwardingSubstitutionMap();
153149
}

lib/SILGen/SILGenFunction.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,10 +1813,6 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
18131813
}
18141814
};
18151815

1816-
/// Return forwarding substitutions for the archetypes in the current
1817-
/// function.
1818-
SubstitutionList getForwardingSubstitutions();
1819-
18201816
/// Return forwarding substitutions for the archetypes in the current
18211817
/// function.
18221818
SubstitutionMap getForwardingSubstitutionMap();

lib/SILGen/SILGenPoly.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,8 +2655,7 @@ buildThunkSignature(SILGenFunction &SGF,
26552655
if (openedExistential == nullptr) {
26562656
auto genericSig = SGF.F.getLoweredFunctionType()->getGenericSignature();
26572657
genericEnv = SGF.F.getGenericEnvironment();
2658-
auto subsArray = SGF.F.getForwardingSubstitutions();
2659-
interfaceSubs = genericSig->getSubstitutionMap(subsArray);
2658+
interfaceSubs = SGF.F.getForwardingSubstitutionMap();
26602659
contextSubs = interfaceSubs;
26612660
return genericSig;
26622661
}
@@ -3015,7 +3014,7 @@ SILGenFunction::createWithoutActuallyEscapingClosure(
30153014
}
30163015

30173016
CanSILFunctionType substFnType = thunkType->substGenericArgs(
3018-
F.getModule(), thunk->getForwardingSubstitutions());
3017+
F.getModule(), thunk->getForwardingSubstitutionMap());
30193018

30203019
// Create it in our current function.
30213020
auto thunkValue = B.createFunctionRef(loc, thunk);

lib/Sema/CalleeCandidateInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ UncurriedCandidate::UncurriedCandidate(ValueDecl *decl, unsigned level)
6565
auto *DC = decl->getInnermostDeclContext();
6666
if (auto *GFT = entityType->getAs<GenericFunctionType>()) {
6767
auto subs = DC->getGenericEnvironmentOfContext()
68-
->getForwardingSubstitutions();
68+
->getForwardingSubstitutionMap();
6969
entityType = GFT->substGenericArgs(subs);
7070
} else {
7171
// FIXME: look through unforced IUOs here?

0 commit comments

Comments
 (0)