Skip to content

Commit 3fcda14

Browse files
committed
AST: ModuleDecl::checkConformance() is a static method
1 parent 1901862 commit 3fcda14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+148
-194
lines changed

lib/AST/ConformanceLookup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ bool TypeBase::isSendableType() {
796796
if (auto *fas = getAs<AnyFunctionType>())
797797
return fas->isSendable();
798798

799-
auto conformance = proto->getParentModule()->checkConformance(
799+
auto conformance = ModuleDecl::checkConformance(
800800
this, proto, false /*allow missing*/);
801801
return conformance && !conformance.hasUnavailableConformance();
802802
}
@@ -849,7 +849,7 @@ static bool conformsToInvertible(CanType type, InvertibleProtocolKind ip) {
849849
SILTokenType>()));
850850

851851
const bool conforms =
852-
(bool) proto->getParentModule()->checkConformance(
852+
(bool) ModuleDecl::checkConformance(
853853
type, proto,
854854
/*allowMissing=*/false);
855855

lib/AST/Decl.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11635,9 +11635,7 @@ ActorIsolation::forActorInstanceParameter(Expr *actor,
1163511635
auto baseType =
1163611636
memberRef->getBase()->getType()->getMetatypeInstanceType();
1163711637
if (auto globalActor = ctx.getProtocol(KnownProtocolKind::GlobalActor)) {
11638-
auto *dc = declRef.getDecl()->getDeclContext();
11639-
auto *module = dc->getParentModule();
11640-
auto conformance = module->checkConformance(baseType, globalActor);
11638+
auto conformance = ModuleDecl::checkConformance(baseType, globalActor);
1164111639
if (conformance &&
1164211640
conformance.getWitnessByName(baseType, ctx.Id_shared) == declRef) {
1164311641
return ActorIsolation::forGlobalActor(baseType);

lib/AST/LifetimeDependence.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,19 @@ static LifetimeDependenceKind getLifetimeDependenceKindFromDecl(
175175
: LifetimeDependenceKind::Inherit;
176176
}
177177

178-
static bool isBitwiseCopyable(Type type, ModuleDecl *mod, ASTContext &ctx) {
178+
static bool isBitwiseCopyable(Type type, ASTContext &ctx) {
179179
auto *bitwiseCopyableProtocol =
180180
ctx.getProtocol(KnownProtocolKind::BitwiseCopyable);
181181
if (!bitwiseCopyableProtocol) {
182182
return false;
183183
}
184-
return (bool)(mod->checkConformance(type, bitwiseCopyableProtocol));
184+
return (bool)(ModuleDecl::checkConformance(type, bitwiseCopyableProtocol));
185185
}
186186

187187
std::optional<LifetimeDependenceInfo>
188188
LifetimeDependenceInfo::fromTypeRepr(AbstractFunctionDecl *afd) {
189189
auto *dc = afd->getDeclContext();
190190
auto &ctx = dc->getASTContext();
191-
auto *mod = afd->getModuleContext();
192191
auto &diags = ctx.Diags;
193192
auto capacity = afd->hasImplicitSelfDecl()
194193
? (afd->getParameters()->size() + 1)
@@ -216,7 +215,7 @@ LifetimeDependenceInfo::fromTypeRepr(AbstractFunctionDecl *afd) {
216215
bool isCompatible = true;
217216
// Lifetime dependence always propagates through temporary BitwiseCopyable
218217
// values, even if the dependence is scoped.
219-
if (!isBitwiseCopyable(paramType, mod, ctx)) {
218+
if (!isBitwiseCopyable(paramType, ctx)) {
220219
isCompatible = isLifetimeDependenceCompatibleWithOwnership(
221220
lifetimeKind, ownership, afd);
222221
}
@@ -416,7 +415,6 @@ std::optional<LifetimeDependenceInfo>
416415
LifetimeDependenceInfo::infer(AbstractFunctionDecl *afd) {
417416
auto *dc = afd->getDeclContext();
418417
auto &ctx = dc->getASTContext();
419-
auto *mod = afd->getModuleContext();
420418

421419
if (!ctx.LangOpts.hasFeature(Feature::NonescapableTypes)) {
422420
return std::nullopt;
@@ -450,7 +448,7 @@ LifetimeDependenceInfo::infer(AbstractFunctionDecl *afd) {
450448
if (!cd && afd->hasImplicitSelfDecl()) {
451449
Type selfTypeInContext = dc->getSelfTypeInContext();
452450
if (selfTypeInContext->isEscapable()) {
453-
if (isBitwiseCopyable(selfTypeInContext, mod, ctx)) {
451+
if (isBitwiseCopyable(selfTypeInContext, ctx)) {
454452
diags.diagnose(
455453
returnLoc,
456454
diag::lifetime_dependence_method_escapable_bitwisecopyable_self);
@@ -483,7 +481,7 @@ LifetimeDependenceInfo::infer(AbstractFunctionDecl *afd) {
483481
}
484482
auto paramOwnership = param->getValueOwnership();
485483
if (paramTypeInContext->isEscapable()) {
486-
if (isBitwiseCopyable(paramTypeInContext, mod, ctx)) {
484+
if (isBitwiseCopyable(paramTypeInContext, ctx)) {
487485
continue;
488486
}
489487
if (paramOwnership == ValueOwnership::Default) {

lib/IDE/ConformingMethodList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ void ConformingMethodListCallbacks::getMatchingMethods(
193193

194194
// The return type conforms to any of the requested protocols.
195195
for (auto Proto : ExpectedTypes) {
196-
if (CurModule->checkConformance(resultTy, Proto))
196+
if (ModuleDecl::checkConformance(resultTy, Proto))
197197
return true;
198198
}
199199

lib/IRGen/GenArchetype.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ const TypeInfo *TypeConverter::convertArchetypeType(ArchetypeType *archetype) {
415415
IGM.getSwiftModule()->getASTContext().getProtocol(
416416
KnownProtocolKind::BitwiseCopyable);
417417
// The protocol won't be present in swiftinterfaces from older SDKs.
418-
if (bitwiseCopyableProtocol && IGM.getSwiftModule()->checkConformance(
418+
if (bitwiseCopyableProtocol && ModuleDecl::checkConformance(
419419
archetype, bitwiseCopyableProtocol)) {
420420
return BitwiseCopyableTypeInfo::create(storageType, abiAccessible);
421421
}

lib/IRGen/GenEnum.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7324,8 +7324,8 @@ ResilientEnumImplStrategy::completeEnumTypeLayout(TypeConverter &TC,
73247324
IGM.getSwiftModule()->getASTContext().getProtocol(
73257325
KnownProtocolKind::BitwiseCopyable);
73267326
if (bitwiseCopyableProtocol &&
7327-
IGM.getSwiftModule()->checkConformance(Type.getASTType(),
7328-
bitwiseCopyableProtocol)) {
7327+
ModuleDecl::checkConformance(Type.getASTType(),
7328+
bitwiseCopyableProtocol)) {
73297329
return BitwiseCopyableTypeInfo::create(enumTy, abiAccessible);
73307330
}
73317331
return registerEnumTypeInfo(

lib/IRGen/GenStruct.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,7 @@ const TypeInfo *TypeConverter::convertStructType(TypeBase *key, CanType type,
16981698
IGM.getSwiftModule()->getASTContext().getProtocol(
16991699
KnownProtocolKind::BitwiseCopyable);
17001700
if (bitwiseCopyableProtocol &&
1701-
IGM.getSwiftModule()->checkConformance(type, bitwiseCopyableProtocol)) {
1701+
ModuleDecl::checkConformance(type, bitwiseCopyableProtocol)) {
17021702
return BitwiseCopyableTypeInfo::create(IGM.OpaqueTy, structAccessible);
17031703
}
17041704
return &getResilientStructTypeInfo(copyable, structAccessible);

lib/IRGen/GenTuple.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ const TypeInfo *TypeConverter::convertTupleType(TupleType *tuple) {
524524
auto *bitwiseCopyableProtocol =
525525
IGM.getSwiftModule()->getASTContext().getProtocol(
526526
KnownProtocolKind::BitwiseCopyable);
527-
if (bitwiseCopyableProtocol && IGM.getSwiftModule()->checkConformance(
527+
if (bitwiseCopyableProtocol && ModuleDecl::checkConformance(
528528
tuple, bitwiseCopyableProtocol)) {
529529
return BitwiseCopyableTypeInfo::create(IGM.OpaqueTy, IsABIAccessible);
530530
}

lib/Refactoring/Async/AsyncHandlerDesc.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ using namespace swift;
1717
using namespace swift::refactoring::asyncrefactorings;
1818

1919
/// Whether the given type is (or conforms to) the stdlib Error type
20-
static bool isErrorType(Type Ty, ModuleDecl *MD) {
20+
static bool isErrorType(Type Ty) {
2121
if (!Ty)
2222
return false;
23-
return !MD->checkConformance(Ty, Ty->getASTContext().getErrorDecl())
23+
return !ModuleDecl::checkConformance(Ty, Ty->getASTContext().getErrorDecl())
2424
.isInvalid();
2525
}
2626

@@ -70,8 +70,7 @@ AsyncHandlerDesc AsyncHandlerDesc::get(const ValueDecl *Handler,
7070
HandlerDesc.Type = HandlerType::PARAMS;
7171
if (!HandlerParams.empty()) {
7272
auto LastParamTy = HandlerParams.back().getParameterType();
73-
HandlerDesc.HasError = isErrorType(LastParamTy->getOptionalObjectType(),
74-
Handler->getModuleContext());
73+
HandlerDesc.HasError = isErrorType(LastParamTy->getOptionalObjectType());
7574
}
7675
}
7776

lib/SIL/IR/AbstractionPattern.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ bool AbstractionPattern::conformsToKnownProtocol(
291291
= substTy->getASTContext().getProtocol(protocolKind);
292292

293293
auto definitelyConforms = [&](CanType t) -> bool {
294-
auto result = suppressible->getParentModule()
295-
->checkConformanceWithoutContext(t, suppressible,
296-
/*allowMissing=*/false);
294+
auto result =
295+
ModuleDecl::checkConformanceWithoutContext(t, suppressible,
296+
/*allowMissing=*/false);
297297
return result.has_value() && !result.value().isInvalid();
298298
};
299299

0 commit comments

Comments
 (0)