Skip to content

Commit ef020c7

Browse files
committed
Eliminate all vestiges of Substitution and SubstitutionList.
Introduced during the bring-up of the generics system in July, 2012, Substitution (and SubstitutionList) has been completely superseded by SubstitutionMap. R.I.P.
1 parent 14b1499 commit ef020c7

34 files changed

+20
-358
lines changed

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "swift/AST/ClangModuleLoader.h"
2222
#include "swift/AST/Identifier.h"
2323
#include "swift/AST/SearchPathOptions.h"
24-
#include "swift/AST/SubstitutionList.h"
2524
#include "swift/AST/Type.h"
2625
#include "swift/AST/TypeAlignments.h"
2726
#include "swift/Basic/LangOptions.h"
@@ -95,7 +94,6 @@ namespace swift {
9594
class SourceManager;
9695
class ValueDecl;
9796
class DiagnosticEngine;
98-
class Substitution;
9997
class TypeCheckerDebugConsumer;
10098
struct RawComment;
10199
class DocComment;

include/swift/AST/GenericEnvironment.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#ifndef SWIFT_AST_GENERIC_ENVIRONMENT_H
1818
#define SWIFT_AST_GENERIC_ENVIRONMENT_H
1919

20-
#include "swift/AST/SubstitutionList.h"
2120
#include "swift/AST/SubstitutionMap.h"
2221
#include "swift/AST/GenericSignature.h"
2322
#include "swift/AST/GenericParamKey.h"

include/swift/AST/GenericSignature.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include "swift/AST/PrintOptions.h"
2121
#include "swift/AST/Requirement.h"
22-
#include "swift/AST/SubstitutionList.h"
2322
#include "swift/AST/Type.h"
2423
#include "llvm/ADT/ArrayRef.h"
2524
#include "llvm/ADT/FoldingSet.h"
@@ -32,7 +31,6 @@ namespace swift {
3231
class GenericSignatureBuilder;
3332
class ProtocolConformanceRef;
3433
class ProtocolType;
35-
class Substitution;
3634
class SubstitutionMap;
3735

3836
/// An access path used to find a particular protocol conformance within
@@ -177,9 +175,9 @@ class alignas(1 << TypeAlignInBits) GenericSignature final
177175
return Mem;
178176
}
179177

180-
/// Build an interface type substitution map from a vector of Substitutions
181-
/// that correspond to the generic parameters in this generic signature.
182-
SubstitutionMap getSubstitutionMap(SubstitutionList args) const;
178+
/// Build a substitution map for this generic signature by looking up
179+
/// substitutions in the given substitution map.
180+
SubstitutionMap getSubstitutionMap(SubstitutionMap subs) const;
183181

184182
/// Build an interface type substitution map from a type substitution function
185183
/// and conformance lookup function.
@@ -193,11 +191,6 @@ class alignas(1 << TypeAlignInBits) GenericSignature final
193191
Optional<ProtocolConformanceRef>
194192
lookupConformance(CanType depTy, ProtocolDecl *proto) const;
195193

196-
/// Build an array of substitutions from an interface type substitution map,
197-
/// using the given function to look up conformances.
198-
void getSubstitutions(const SubstitutionMap &subMap,
199-
SmallVectorImpl<Substitution> &result) const;
200-
201194
/// Enumerate all of the dependent types in the type signature that will
202195
/// occur in substitution lists (in order), along with the set of
203196
/// conformance requirements placed on that dependent type.

include/swift/AST/LazyResolver.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class NominalTypeDecl;
3333
class NormalProtocolConformance;
3434
class ProtocolConformance;
3535
class ProtocolDecl;
36-
class Substitution;
3736
class TypeDecl;
3837
class ValueDecl;
3938
class VarDecl;

include/swift/AST/ProtocolConformance.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include "swift/AST/ConcreteDeclRef.h"
2020
#include "swift/AST/Decl.h"
21-
#include "swift/AST/SubstitutionList.h"
2221
#include "swift/AST/Type.h"
2322
#include "swift/AST/Types.h"
2423
#include "swift/AST/TypeAlignments.h"

include/swift/AST/Substitution.h

Lines changed: 0 additions & 64 deletions
This file was deleted.

include/swift/AST/SubstitutionList.h

Lines changed: 0 additions & 39 deletions
This file was deleted.

include/swift/AST/SubstitutionMap.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,9 @@ namespace swift {
3131

3232
class GenericSignature;
3333
class GenericEnvironment;
34-
class Substitution;
3534
class SubstitutableType;
3635
typedef CanTypeWrapper<GenericTypeParamType> CanGenericTypeParamType;
3736

38-
// FIXME: Soon this will go away.
39-
using SubstitutionList = ArrayRef<Substitution>;
40-
4137
template<class Type> class CanTypeWrapper;
4238
typedef CanTypeWrapper<SubstitutableType> CanSubstitutableType;
4339

@@ -109,10 +105,9 @@ class SubstitutionMap {
109105
}
110106

111107
/// Build an interface type substitution map for the given generic
112-
/// signature and a vector of Substitutions that correspond to the
113-
/// requirements of this generic signature.
108+
/// signature using the mapping in the given substitutions.
114109
static SubstitutionMap get(GenericSignature *genericSig,
115-
SubstitutionList substitutions);
110+
SubstitutionMap substitutions);
116111

117112
/// Build an interface type substitution map for the given generic signature
118113
/// from a type substitution function and conformance lookup function.
@@ -196,14 +191,6 @@ class SubstitutionMap {
196191
GenericSignature *derivedSig,
197192
Optional<SubstitutionMap> derivedSubs);
198193

199-
/// Produce a substitution list for the given substitution map.
200-
///
201-
/// Note: we are moving away from using Substitutions, so this should only
202-
/// be used at the edges where part of the compiler is still working
203-
/// directly with Substitution/SubstitutionList and hasn't been converted
204-
/// to SubstitutionMap.
205-
SubstitutionList toList() const;
206-
207194
/// Combine two substitution maps as follows.
208195
///
209196
/// The result is written in terms of the generic parameters of 'genericSig'.

include/swift/AST/TypeAlignments.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ namespace swift {
4545
class ProtocolConformance;
4646
class SILFunction;
4747
class Stmt;
48-
class Substitution;
4948
class TypeVariableType;
5049
class TypeBase;
5150
class TypeDecl;

include/swift/AST/Types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "swift/AST/ProtocolConformanceRef.h"
2525
#include "swift/AST/Requirement.h"
2626
#include "swift/AST/SILLayout.h"
27-
#include "swift/AST/SubstitutionList.h"
2827
#include "swift/AST/SubstitutionMap.h"
2928
#include "swift/AST/Type.h"
3029
#include "swift/AST/TypeAlignments.h"

include/swift/AST/Witness.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#define SWIFT_AST_WITNESS_H
2020

2121
#include "swift/AST/ConcreteDeclRef.h"
22-
#include "swift/AST/SubstitutionList.h"
2322
#include "llvm/ADT/PointerUnion.h"
2423
#include "llvm/Support/Compiler.h"
2524

include/swift/SIL/SILInstruction.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class SILArgument;
6565
class SILUndef;
6666
class Stmt;
6767
class StringLiteralExpr;
68-
class Substitution;
6968
class ValueDecl;
7069
class VarDecl;
7170
class FunctionRefInst;

include/swift/SIL/TypeSubstCloner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
7777
RecursiveSubs = AI.getFunction()
7878
->getLoweredFunctionType()
7979
->getGenericSignature()
80-
->getSubstitutionMap(Subs.toList());
80+
->getSubstitutionMap(Subs);
8181

8282
// Use the new set of substitutions to compute the new
8383
// substituted callee type.

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2792,20 +2792,6 @@ void TypeRepr::dump() const {
27922792
llvm::errs() << '\n';
27932793
}
27942794

2795-
void Substitution::dump() const {
2796-
dump(llvm::errs());
2797-
}
2798-
2799-
void Substitution::dump(llvm::raw_ostream &out, unsigned indent) const {
2800-
out.indent(indent);
2801-
print(out);
2802-
out << '\n';
2803-
2804-
for (auto &c : Conformance) {
2805-
c.dump(out, indent + 2);
2806-
}
2807-
}
2808-
28092795
void ProtocolConformanceRef::dump() const {
28102796
dump(llvm::errs());
28112797
}
@@ -2822,14 +2808,6 @@ void ProtocolConformanceRef::dump(llvm::raw_ostream &out,
28222808
}
28232809
}
28242810

2825-
void swift::dump(SubstitutionList subs) {
2826-
unsigned i = 0;
2827-
for (const auto &s : subs) {
2828-
llvm::errs() << i++ << ": ";
2829-
s.dump();
2830-
}
2831-
}
2832-
28332811
void ProtocolConformance::dump() const {
28342812
auto &out = llvm::errs();
28352813
dump(out);

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4176,11 +4176,6 @@ void ProtocolConformance::printName(llvm::raw_ostream &os,
41764176
}
41774177
}
41784178

4179-
void Substitution::print(llvm::raw_ostream &os,
4180-
const PrintOptions &PO) const {
4181-
Replacement->print(os, PO);
4182-
}
4183-
41844179
void swift::printEnumElementsAsCases(
41854180
llvm::DenseSet<EnumElementDecl *> &UnhandledElements,
41864181
llvm::raw_ostream &OS) {

lib/AST/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ add_swift_library(swiftAST STATIC
4848
SyntaxASTMap.cpp
4949
SILLayout.cpp
5050
Stmt.cpp
51-
Substitution.cpp
5251
SubstitutionMap.cpp
5352
SwiftNameTranslation.cpp
5453
Type.cpp

lib/AST/GenericSignature.cpp

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ bool GenericSignature::enumeratePairedRequirements(
466466
}
467467

468468
SubstitutionMap
469-
GenericSignature::getSubstitutionMap(SubstitutionList subs) const {
469+
GenericSignature::getSubstitutionMap(SubstitutionMap subs) const {
470470
return SubstitutionMap::get(const_cast<GenericSignature *>(this), subs);
471471
}
472472

@@ -478,43 +478,6 @@ getSubstitutionMap(TypeSubstitutionFn subs,
478478
subs, lookupConformance);
479479
}
480480

481-
void GenericSignature::
482-
getSubstitutions(const SubstitutionMap &subMap,
483-
SmallVectorImpl<Substitution> &result) const {
484-
485-
// Enumerate all of the requirements that require substitution.
486-
enumeratePairedRequirements([&](Type depTy, ArrayRef<Requirement> reqs) {
487-
auto &ctx = getASTContext();
488-
489-
// Compute the replacement type.
490-
Type currentReplacement = depTy.subst(subMap);
491-
if (!currentReplacement)
492-
currentReplacement = ErrorType::get(depTy);
493-
494-
// Collect the conformances.
495-
SmallVector<ProtocolConformanceRef, 4> currentConformances;
496-
for (auto req: reqs) {
497-
assert(req.getKind() == RequirementKind::Conformance);
498-
auto protoDecl = req.getSecondType()->castTo<ProtocolType>()->getDecl();
499-
if (auto conformance = subMap.lookupConformance(depTy->getCanonicalType(),
500-
protoDecl)) {
501-
currentConformances.push_back(*conformance);
502-
} else {
503-
if (!currentReplacement->hasError())
504-
currentReplacement = ErrorType::get(currentReplacement);
505-
currentConformances.push_back(ProtocolConformanceRef(protoDecl));
506-
}
507-
}
508-
509-
// Add it to the final substitution list.
510-
result.push_back({
511-
currentReplacement,
512-
ctx.AllocateCopy(currentConformances)
513-
});
514-
515-
return false;
516-
});
517-
}
518481

519482
bool GenericSignature::requiresClass(Type type) {
520483
if (!type->isTypeParameter()) return false;

0 commit comments

Comments
 (0)