Skip to content

Commit d75b34b

Browse files
authored
Merge pull request swiftlang#38753 from CodaFi/modulo-modules
[NFC] Remove Unused Module Parameter to Conformance Lookup
2 parents 7cf32d2 + 8082205 commit d75b34b

20 files changed

+20
-37
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3239,16 +3239,13 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
32393239
/// Look for conformances of this nominal type to the given
32403240
/// protocol.
32413241
///
3242-
/// \param module The module from which we initiate the search.
3243-
/// FIXME: This is currently unused.
3244-
///
32453242
/// \param protocol The protocol whose conformance is requested.
32463243
/// \param conformances Will be populated with the set of protocol
32473244
/// conformances found for this protocol.
32483245
///
32493246
/// \returns true if any conformances were found.
32503247
bool lookupConformance(
3251-
ModuleDecl *module, ProtocolDecl *protocol,
3248+
ProtocolDecl *protocol,
32523249
SmallVectorImpl<ProtocolConformance *> &conformances) const;
32533250

32543251
/// Retrieve all of the protocols that this nominal type conforms to.

lib/AST/ConformanceLookupTable.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,6 @@ void ConformanceLookupTable::registerProtocolConformance(
950950
}
951951

952952
bool ConformanceLookupTable::lookupConformance(
953-
ModuleDecl *module,
954953
NominalTypeDecl *nominal,
955954
ProtocolDecl *protocol,
956955
SmallVectorImpl<ProtocolConformance *> &conformances) {

lib/AST/ConformanceLookupTable.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,7 @@ class ConformanceLookupTable {
445445
/// conformances found for this protocol and nominal type.
446446
///
447447
/// \returns true if any conformances were found.
448-
bool lookupConformance(ModuleDecl *module,
449-
NominalTypeDecl *nominal,
448+
bool lookupConformance(NominalTypeDecl *nominal,
450449
ProtocolDecl *protocol,
451450
SmallVectorImpl<ProtocolConformance *> &conformances);
452451

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3133,7 +3133,7 @@ bool ValueDecl::canInferObjCFromRequirement(ValueDecl *requirement) {
31333133
// If the nominal type doesn't conform to the protocol at all, we
31343134
// cannot infer @objc no matter what we do.
31353135
SmallVector<ProtocolConformance *, 1> conformances;
3136-
if (!nominal->lookupConformance(getModuleContext(), proto, conformances))
3136+
if (!nominal->lookupConformance(proto, conformances))
31373137
return false;
31383138

31393139
// If any of the conformances is attributed to the context in which

lib/AST/Module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ LookupConformanceInModuleRequest::evaluate(
12321232

12331233
// Find the (unspecialized) conformance.
12341234
SmallVector<ProtocolConformance *, 2> conformances;
1235-
if (!nominal->lookupConformance(mod, protocol, conformances)) {
1235+
if (!nominal->lookupConformance(protocol, conformances)) {
12361236
if (!protocol->isSpecificProtocol(KnownProtocolKind::Sendable))
12371237
return getInvalidOrMissingConformance(type, protocol);
12381238

lib/AST/ProtocolConformance.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,11 +1284,10 @@ void NominalTypeDecl::prepareConformanceTable() const {
12841284
}
12851285

12861286
bool NominalTypeDecl::lookupConformance(
1287-
ModuleDecl *module, ProtocolDecl *protocol,
1287+
ProtocolDecl *protocol,
12881288
SmallVectorImpl<ProtocolConformance *> &conformances) const {
12891289
prepareConformanceTable();
12901290
return ConformanceTable->lookupConformance(
1291-
module,
12921291
const_cast<NominalTypeDecl *>(this),
12931292
protocol,
12941293
conformances);

lib/AST/Type.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,9 +2639,7 @@ getForeignRepresentable(Type type, ForeignLanguage language,
26392639
if (auto objcBridgeable
26402640
= ctx.getProtocol(KnownProtocolKind::ObjectiveCBridgeable)) {
26412641
SmallVector<ProtocolConformance *, 1> conformances;
2642-
if (nominal->lookupConformance(dc->getParentModule(),
2643-
objcBridgeable,
2644-
conformances))
2642+
if (nominal->lookupConformance(objcBridgeable, conformances))
26452643
break;
26462644
}
26472645
}

lib/ClangImporter/ImportType.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,7 @@ namespace {
589589
auto nominal = element->getAnyNominal();
590590
auto simdscalar = Impl.SwiftContext.getProtocol(KnownProtocolKind::SIMDScalar);
591591
SmallVector<ProtocolConformance *, 2> conformances;
592-
if (simdscalar && nominal->lookupConformance(nominal->getParentModule(),
593-
simdscalar, conformances)) {
592+
if (simdscalar && nominal->lookupConformance(simdscalar, conformances)) {
594593
// Element type conforms to SIMDScalar. Get the SIMDn generic type
595594
// if it exists.
596595
SmallString<8> name("SIMD");
@@ -2807,8 +2806,7 @@ bool ClangImporter::Implementation::matchesHashableBound(Type type) {
28072806
auto hashable = SwiftContext.getProtocol(KnownProtocolKind::Hashable);
28082807
SmallVector<ProtocolConformance *, 2> conformances;
28092808
return hashable &&
2810-
nominal->lookupConformance(nominal->getParentModule(), hashable,
2811-
conformances);
2809+
nominal->lookupConformance(hashable, conformances);
28122810
}
28132811

28142812
return false;

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ class InheritedProtocolCollector {
502502
const NominalTypeDecl *nominal,
503503
ProtocolDecl *proto) {
504504
SmallVector<ProtocolConformance *, 4> conformances;
505-
nominal->lookupConformance(M, proto, conformances);
505+
nominal->lookupConformance(proto, conformances);
506506
return llvm::all_of(conformances,
507507
[M](const ProtocolConformance *conformance) -> bool {
508508
return M == conformance->getDeclContext()->getParentModule();

lib/IDE/CodeCompletion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4349,7 +4349,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
43494349
// Check for conformance to the literal protocol.
43504350
if (auto *NTD = T->getAnyNominal()) {
43514351
SmallVector<ProtocolConformance *, 2> conformances;
4352-
if (NTD->lookupConformance(CurrModule, P, conformances)) {
4352+
if (NTD->lookupConformance(P, conformances)) {
43534353
addTypeAnnotation(builder, T);
43544354
builder.setExpectedTypeRelation(typeRelation);
43554355
return;

lib/PrintAsObjC/DeclAndTypePrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ class DeclAndTypePrinter::Implementation
13121312

13131313
// Determine whether this nominal type is _ObjectiveCBridgeable.
13141314
SmallVector<ProtocolConformance *, 2> conformances;
1315-
if (!nominal->lookupConformance(&owningPrinter.M, proto, conformances))
1315+
if (!nominal->lookupConformance(proto, conformances))
13161316
return nullptr;
13171317

13181318
// Dig out the Objective-C type.

lib/PrintAsObjC/ModuleContentsWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ class ModuleWriter {
449449

450450
SmallVector<ProtocolConformance *, 1> conformances;
451451
auto errorTypeProto = ctx.getProtocol(KnownProtocolKind::Error);
452-
if (ED->lookupConformance(&M, errorTypeProto, conformances)) {
452+
if (ED->lookupConformance(errorTypeProto, conformances)) {
453453
bool hasDomainCase = std::any_of(ED->getAllElements().begin(),
454454
ED->getAllElements().end(),
455455
[](const EnumElementDecl *elem) {

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7036,8 +7036,7 @@ allFromConditionalConformances(DeclContext *DC, Type baseTy,
70367036

70377037
if (auto *protocol = candidateDC->getSelfProtocolDecl()) {
70387038
SmallVector<ProtocolConformance *, 4> conformances;
7039-
if (!NTD->lookupConformance(DC->getParentModule(), protocol,
7040-
conformances))
7039+
if (!NTD->lookupConformance(protocol, conformances))
70417040
return false;
70427041

70437042
// This is opportunistic, there should be a way to narrow the

lib/Sema/ConstraintSystem.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5878,7 +5878,6 @@ bool TypeVarBindingProducer::requiresOptionalAdjustment(
58785878
if (auto *nominalBindingDecl = type->getAnyNominal()) {
58795879
SmallVector<ProtocolConformance *, 2> conformances;
58805880
conformsToExprByNilLiteral = nominalBindingDecl->lookupConformance(
5881-
CS.DC->getParentModule(),
58825881
CS.getASTContext().getProtocol(
58835882
KnownProtocolKind::ExpressibleByNilLiteral),
58845883
conformances);

lib/Sema/PreCheckExpr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,8 +2043,7 @@ Expr *PreCheckExpression::simplifyTypeConstructionWithLiteralArg(Expr *E) {
20432043
}
20442044

20452045
SmallVector<ProtocolConformance *, 2> conformances;
2046-
return castTy->getAnyNominal()->lookupConformance(DC->getParentModule(),
2047-
protocol, conformances)
2046+
return castTy->getAnyNominal()->lookupConformance(protocol, conformances)
20482047
? CoerceExpr::forLiteralInit(getASTContext(), argExpr,
20492048
call->getSourceRange(),
20502049
typeExpr->getTypeRepr())

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2910,7 +2910,7 @@ void AttributeChecker::visitImplementsAttr(ImplementsAttr *attr) {
29102910
// conforms to the specified protocol.
29112911
NominalTypeDecl *NTD = DC->getSelfNominalTypeDecl();
29122912
SmallVector<ProtocolConformance *, 2> conformances;
2913-
if (!NTD->lookupConformance(DC->getParentModule(), PD, conformances)) {
2913+
if (!NTD->lookupConformance(PD, conformances)) {
29142914
diagnose(attr->getLocation(),
29152915
diag::implements_attr_protocol_not_conformed_to,
29162916
NTD->getName(), PD->getName())

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6222,8 +6222,7 @@ swift::findWitnessedObjCRequirements(const ValueDecl *witness,
62226222
// Dig out the conformance.
62236223
if (!conformance.hasValue()) {
62246224
SmallVector<ProtocolConformance *, 2> conformances;
6225-
nominal->lookupConformance(dc->getParentModule(), proto,
6226-
conformances);
6225+
nominal->lookupConformance(proto, conformances);
62276226
if (conformances.size() == 1)
62286227
conformance = conformances.front();
62296228
else

lib/Sema/TypeCheckStmt.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ static void tryDiagnoseUnnecessaryCastOverOptionSet(ASTContext &Ctx,
229229
if (!optionSetType)
230230
return;
231231
SmallVector<ProtocolConformance *, 4> conformances;
232-
if (!(optionSetType &&
233-
NTD->lookupConformance(module, optionSetType, conformances)))
232+
if (!(optionSetType && NTD->lookupConformance(optionSetType, conformances)))
234233
return;
235234

236235
auto *CE = dyn_cast<CallExpr>(E);

lib/Sema/TypeCheckStorage.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ static void computeLoweredStoredProperties(NominalTypeDecl *decl) {
128128

129129
if (auto actorProto = ctx.getProtocol(KnownProtocolKind::Actor)) {
130130
SmallVector<ProtocolConformance *, 1> conformances;
131-
classDecl->lookupConformance(
132-
decl->getModuleContext(), actorProto, conformances);
131+
classDecl->lookupConformance(actorProto, conformances);
133132
for (auto conformance : conformances)
134133
TypeChecker::checkConformance(conformance->getRootNormalConformance());
135134
}
@@ -138,8 +137,7 @@ static void computeLoweredStoredProperties(NominalTypeDecl *decl) {
138137
if (classDecl->isDistributedActor()) {
139138
if (auto actorProto = ctx.getProtocol(KnownProtocolKind::DistributedActor)) {
140139
SmallVector<ProtocolConformance *, 1> conformances;
141-
classDecl->lookupConformance(
142-
decl->getModuleContext(), actorProto, conformances);
140+
classDecl->lookupConformance(actorProto, conformances);
143141
for (auto conformance : conformances)
144142
TypeChecker::checkConformance(conformance->getRootNormalConformance());
145143
}

lib/Serialization/Deserialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ ModuleFile::readConformanceChecked(llvm::BitstreamCursor &Cursor,
609609
module = getAssociatedModule();
610610

611611
SmallVector<ProtocolConformance *, 2> conformances;
612-
nominal->lookupConformance(module, proto, conformances);
612+
nominal->lookupConformance(proto, conformances);
613613
PrettyStackTraceModuleFile traceMsg(
614614
"If you're seeing a crash here, check that your SDK and dependencies "
615615
"are at least as new as the versions used to build", *this);

0 commit comments

Comments
 (0)