Skip to content

Commit a11f9c3

Browse files
committed
[AST] Remove ModuleDecl from TypeBase::getCanonicalType().
1 parent 1f1b75a commit a11f9c3

File tree

9 files changed

+18
-35
lines changed

9 files changed

+18
-35
lines changed

include/swift/AST/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
393393

394394
/// getCanonicalType - Stronger canonicalization which folds away equivalent
395395
/// associated types, or type parameters that have been made concrete.
396-
CanType getCanonicalType(GenericSignature *sig, ModuleDecl &mod);
396+
CanType getCanonicalType(GenericSignature *sig);
397397

398398
/// Reconstitute type sugar, e.g., for array types, dictionary
399399
/// types, optionals, etc.

lib/AST/Type.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,12 +1143,10 @@ CanType TypeBase::getCanonicalType() {
11431143
->getCanonicalSignature();
11441144

11451145
// Transform the input and result types.
1146-
auto &ctx = function->getInput()->getASTContext();
1147-
auto &mod = *ctx.TheBuiltinModule;
11481146
auto inputTy = getCanonicalInputType(function, [&](Type type) -> CanType {
1149-
return type->getCanonicalType(sig, mod);
1147+
return type->getCanonicalType(sig);
11501148
});
1151-
auto resultTy = function->getResult()->getCanonicalType(sig, mod);
1149+
auto resultTy = function->getResult()->getCanonicalType(sig);
11521150
Result = GenericFunctionType::get(sig, inputTy, resultTy,
11531151
function->getExtInfo());
11541152
assert(Result->isCanonical());
@@ -1234,8 +1232,7 @@ CanType TypeBase::getCanonicalType() {
12341232
return CanType(Result);
12351233
}
12361234

1237-
CanType TypeBase::getCanonicalType(GenericSignature *sig,
1238-
ModuleDecl &mod) {
1235+
CanType TypeBase::getCanonicalType(GenericSignature *sig) {
12391236
if (!sig)
12401237
return getCanonicalType();
12411238

lib/SIL/AbstractionPattern.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ TypeConverter::getIndicesAbstractionPattern(SubscriptDecl *decl) {
5353
if (auto sig = decl->getGenericSignatureOfContext())
5454
genericSig = sig->getCanonicalSignature();
5555
auto indicesTy = decl->getIndicesInterfaceType();
56-
auto indicesCanTy = indicesTy->getCanonicalType(genericSig,
57-
*decl->getParentModule());
56+
auto indicesCanTy = indicesTy->getCanonicalType(genericSig);
5857
return AbstractionPattern(genericSig, indicesCanTy);
5958
}
6059

lib/SIL/SILFunctionType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ static CanSILFunctionType getSILFunctionType(SILModule &M,
870870
auto origGenericSig
871871
= function->getGenericSignature();
872872
auto getCanonicalType = [origGenericSig, &M](Type t) -> CanType {
873-
return t->getCanonicalType(origGenericSig, *M.getSwiftModule());
873+
return t->getCanonicalType(origGenericSig);
874874
};
875875

876876
auto &Types = M.Types;

lib/SIL/TypeLowering.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,9 +1735,7 @@ static CanAnyFunctionType getDefaultArgGeneratorInterfaceType(
17351735

17361736
// The result type might be written in terms of type parameters
17371737
// that have been made fully concrete.
1738-
CanType canResultTy = resultTy->getCanonicalType(
1739-
AFD->getGenericSignature(),
1740-
*TC.M.getSwiftModule());
1738+
CanType canResultTy = resultTy->getCanonicalType(AFD->getGenericSignature());
17411739

17421740
// Get the generic signature from the surrounding context.
17431741
auto funcInfo = TC.getConstantInfo(SILDeclRef(AFD));
@@ -1766,8 +1764,7 @@ static CanAnyFunctionType getDestructorInterfaceType(TypeConverter &TC,
17661764
bool isDeallocating,
17671765
bool isForeign) {
17681766
auto classType = dd->getDeclContext()->getDeclaredInterfaceType()
1769-
->getCanonicalType(dd->getGenericSignatureOfContext(),
1770-
*TC.M.getSwiftModule());
1767+
->getCanonicalType(dd->getGenericSignatureOfContext());
17711768

17721769
assert((!isForeign || isDeallocating)
17731770
&& "There are no foreign destroying destructors");
@@ -1797,8 +1794,7 @@ static CanAnyFunctionType getIVarInitDestroyerInterfaceType(TypeConverter &TC,
17971794
bool isObjC,
17981795
bool isDestroyer) {
17991796
auto classType = cd->getDeclaredInterfaceType()
1800-
->getCanonicalType(cd->getGenericSignatureOfContext(),
1801-
*TC.M.getSwiftModule());
1797+
->getCanonicalType(cd->getGenericSignatureOfContext());
18021798

18031799
CanType emptyTupleTy = TupleType::getEmpty(TC.Context);
18041800
auto resultType = (isDestroyer ? emptyTupleTy : classType);
@@ -2095,10 +2091,8 @@ getMaterializeForSetCallbackType(AbstractStorageDecl *storage,
20952091
}
20962092
}
20972093

2098-
auto canSelfType = selfType->getCanonicalType(
2099-
genericSig, *M.getSwiftModule());
2100-
auto canSelfMetatypeType = selfMetatypeType->getCanonicalType(
2101-
genericSig, *M.getSwiftModule());
2094+
auto canSelfType = selfType->getCanonicalType(genericSig);
2095+
auto canSelfMetatypeType = selfMetatypeType->getCanonicalType(genericSig);
21022096

21032097
// Create the SILFunctionType for the callback.
21042098
SILParameterInfo params[] = {
@@ -2508,7 +2502,7 @@ TypeConverter::getContextBoxTypeForCapture(ValueDecl *captured,
25082502
->getGenericSignatureOfContext();
25092503
loweredInterfaceType =
25102504
env->mapTypeOutOfContext(loweredInterfaceType)
2511-
->getCanonicalType(homeSig, *M.getSwiftModule());
2505+
->getCanonicalType(homeSig);
25122506
}
25132507

25142508
auto boxType = getInterfaceBoxTypeForCapture(captured,

lib/SILGen/SILGenMaterializeForSet.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,7 @@ struct MaterializeForSetEmitter {
434434
}
435435

436436
CanType witnessSelfType =
437-
computeSelfParam(Witness).getType()->getCanonicalType(
438-
GenericSig, *SGM.M.getSwiftModule());
437+
computeSelfParam(Witness).getType()->getCanonicalType(GenericSig);
439438
witnessSelfType = getSubstWitnessInterfaceType(witnessSelfType);
440439

441440
// Get the inout object type, but remember whether we needed to.
@@ -661,8 +660,7 @@ collectIndicesFromParameters(SILGenFunction &SGF, SILLocation loc,
661660
auto witnessSubscript = cast<SubscriptDecl>(WitnessStorage);
662661
CanType witnessIndicesType =
663662
witnessSubscript->getIndicesInterfaceType()
664-
->getCanonicalType(GenericSig,
665-
*SGM.M.getSwiftModule());
663+
->getCanonicalType(GenericSig);
666664
CanType substIndicesType =
667665
getSubstWitnessInterfaceType(witnessIndicesType);
668666

lib/SILGen/SILGenPoly.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,9 +2822,8 @@ CanSILFunctionType SILGenFunction::buildThunkType(
28222822
? DefaultThickCalleeConvention
28232823
: ParameterConvention::Direct_Unowned});
28242824

2825-
auto &mod = *F.getModule().getSwiftModule();
28262825
auto getCanonicalType = [&](Type t) -> CanType {
2827-
return t->getCanonicalType(genericSig, mod);
2826+
return t->getCanonicalType(genericSig);
28282827
};
28292828

28302829
// Map the parameter and expected types out of context to get the interface

lib/SILGen/SILGenProlog.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,7 @@ unsigned SILGenFunction::emitProlog(ArrayRef<ParameterList *> paramLists,
501501
bool throws) {
502502
// Create the indirect result parameters.
503503
auto *genericSig = DC->getGenericSignatureOfContext();
504-
resultType = resultType->getCanonicalType(genericSig,
505-
*SGM.M.getSwiftModule());
504+
resultType = resultType->getCanonicalType(genericSig);
506505

507506
emitIndirectResultParameters(*this, resultType, DC);
508507

lib/Sema/TypeCheckDecl.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5978,12 +5978,9 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
59785978
// Canonicalize with respect to the override's generic signature, if any.
59795979
auto *genericSig = decl->getInnermostDeclContext()
59805980
->getGenericSignatureOfContext();
5981-
auto *module = dc->getParentModule();
59825981

5983-
auto canDeclTy =
5984-
declTy->getCanonicalType(genericSig, *module);
5985-
auto canParentDeclTy =
5986-
parentDeclTy->getCanonicalType(genericSig, *module);
5982+
auto canDeclTy = declTy->getCanonicalType(genericSig);
5983+
auto canParentDeclTy = parentDeclTy->getCanonicalType(genericSig);
59875984

59885985
if (canDeclTy == canParentDeclTy) {
59895986
matches.push_back({parentDecl, true, parentDeclTy});

0 commit comments

Comments
 (0)