Skip to content

Commit 620b805

Browse files
committed
AST: Remove SILType variant of ArchetypeBuilder::substDependentType()
This is no longer needed.
1 parent c965a3c commit 620b805

File tree

2 files changed

+0
-103
lines changed

2 files changed

+0
-103
lines changed

include/swift/AST/ArchetypeBuilder.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class ProtocolConformance;
4949
class ProtocolDecl;
5050
class Requirement;
5151
class RequirementRepr;
52-
class SILModule;
5352
class SourceLoc;
5453
class Type;
5554
class TypeRepr;
@@ -336,18 +335,6 @@ class ArchetypeBuilder {
336335

337336
/// Dump all of the requirements to the given output stream.
338337
void dump(llvm::raw_ostream &out);
339-
340-
// In SILFunction.cpp:
341-
342-
/// \brief Resolve the given dependent type using our context archetypes.
343-
///
344-
/// Given an arbitrary type, this will substitute dependent type parameters
345-
/// structurally with their corresponding archetypes and resolve dependent
346-
/// member types to the appropriate associated types. It will reabstract
347-
/// dependent types according to the abstraction level of their associated
348-
/// type requirements.
349-
SILType substDependentType(SILModule &M,
350-
SILType type);
351338
};
352339

353340
class ArchetypeBuilder::PotentialArchetype {

lib/SIL/SILFunction.cpp

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -177,96 +177,6 @@ Type SILFunction::mapTypeIntoContext(Type type) const {
177177
type);
178178
}
179179

180-
namespace {
181-
template<typename SubstFn>
182-
struct SubstDependentSILType
183-
: CanTypeVisitor<SubstDependentSILType<SubstFn>, CanType>
184-
{
185-
SILModule &M;
186-
SubstFn Subst;
187-
188-
SubstDependentSILType(SILModule &M, SubstFn Subst)
189-
: M(M), Subst(std::move(Subst))
190-
{}
191-
192-
using super = CanTypeVisitor<SubstDependentSILType<SubstFn>, CanType>;
193-
using super::visit;
194-
195-
CanType visitDependentMemberType(CanDependentMemberType t) {
196-
// If a dependent member type appears in lowered position, we need to lower
197-
// its context substitution against the associated type's abstraction
198-
// pattern.
199-
CanType astTy = Subst(t);
200-
auto origTy = AbstractionPattern::getOpaque();
201-
202-
return M.Types.getLoweredType(origTy, astTy)
203-
.getSwiftRValueType();
204-
}
205-
206-
CanType visitTupleType(CanTupleType t) {
207-
// Dependent members can appear in lowered position inside tuples.
208-
209-
SmallVector<TupleTypeElt, 4> elements;
210-
211-
for (auto &elt : t->getElements())
212-
elements.push_back(elt.getWithType(visit(CanType(elt.getType()))));
213-
214-
return TupleType::get(elements, t->getASTContext())
215-
->getCanonicalType();
216-
}
217-
218-
CanType visitSILFunctionType(CanSILFunctionType t) {
219-
// Dependent members can appear in lowered position inside SIL functions.
220-
221-
SmallVector<SILParameterInfo, 4> params;
222-
for (auto &param : t->getParameters())
223-
params.push_back(param.map([&](CanType pt) -> CanType {
224-
return visit(pt);
225-
}));
226-
227-
SmallVector<SILResultInfo, 4> results;
228-
for (auto &result : t->getAllResults())
229-
results.push_back(result.map([&](CanType pt) -> CanType {
230-
return visit(pt);
231-
}));
232-
233-
Optional<SILResultInfo> errorResult;
234-
if (t->hasErrorResult()) {
235-
errorResult = t->getErrorResult().map([&](CanType elt) -> CanType {
236-
return visit(elt);
237-
});
238-
}
239-
240-
return SILFunctionType::get(t->getGenericSignature(),
241-
t->getExtInfo(),
242-
t->getCalleeConvention(),
243-
params, results, errorResult,
244-
t->getASTContext());
245-
}
246-
247-
CanType visitType(CanType t) {
248-
// Other types get substituted into context normally.
249-
return Subst(t);
250-
}
251-
};
252-
253-
template<typename SubstFn>
254-
SILType doSubstDependentSILType(SILModule &M,
255-
SubstFn Subst,
256-
SILType t) {
257-
CanType result = SubstDependentSILType<SubstFn>(M, std::move(Subst))
258-
.visit(t.getSwiftRValueType());
259-
return SILType::getPrimitiveType(result, t.getCategory());
260-
}
261-
262-
} // end anonymous namespace
263-
264-
SILType ArchetypeBuilder::substDependentType(SILModule &M, SILType type) {
265-
return doSubstDependentSILType(M,
266-
[&](CanType t) { return substDependentType(t)->getCanonicalType(); },
267-
type);
268-
}
269-
270180
SILType SILFunction::mapTypeIntoContext(SILType type) const {
271181
if (getGenericEnvironment() == nullptr)
272182
return type;

0 commit comments

Comments
 (0)