Skip to content

Commit 8082205

Browse files
committed
[NFC] Remove Unused Module Parameter to Conformance Lookup
It's been quite a long time since this unused parameter was introduced. The intent is to produce the module as a root for the search - that is, computing the set of conformances visible from that module, not the set of conformances inside of that module. Callers have since been providing all manner of module-scoped contexts to it. Let's just get rid of it. When we want to teach protocol conformance lookup to do this, we can revert this commit as a starting point and try again.
1 parent 0580357 commit 8082205

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
@@ -3227,16 +3227,13 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
32273227
/// Look for conformances of this nominal type to the given
32283228
/// protocol.
32293229
///
3230-
/// \param module The module from which we initiate the search.
3231-
/// FIXME: This is currently unused.
3232-
///
32333230
/// \param protocol The protocol whose conformance is requested.
32343231
/// \param conformances Will be populated with the set of protocol
32353232
/// conformances found for this protocol.
32363233
///
32373234
/// \returns true if any conformances were found.
32383235
bool lookupConformance(
3239-
ModuleDecl *module, ProtocolDecl *protocol,
3236+
ProtocolDecl *protocol,
32403237
SmallVectorImpl<ProtocolConformance *> &conformances) const;
32413238

32423239
/// 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
@@ -3129,7 +3129,7 @@ bool ValueDecl::canInferObjCFromRequirement(ValueDecl *requirement) {
31293129
// If the nominal type doesn't conform to the protocol at all, we
31303130
// cannot infer @objc no matter what we do.
31313131
SmallVector<ProtocolConformance *, 1> conformances;
3132-
if (!nominal->lookupConformance(getModuleContext(), proto, conformances))
3132+
if (!nominal->lookupConformance(proto, conformances))
31333133
return false;
31343134

31353135
// 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
@@ -1180,7 +1180,7 @@ LookupConformanceInModuleRequest::evaluate(
11801180

11811181
// Find the (unspecialized) conformance.
11821182
SmallVector<ProtocolConformance *, 2> conformances;
1183-
if (!nominal->lookupConformance(mod, protocol, conformances)) {
1183+
if (!nominal->lookupConformance(protocol, conformances)) {
11841184
if (!protocol->isSpecificProtocol(KnownProtocolKind::Sendable))
11851185
return ProtocolConformanceRef::forInvalid();
11861186

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
@@ -2638,9 +2638,7 @@ getForeignRepresentable(Type type, ForeignLanguage language,
26382638
if (auto objcBridgeable
26392639
= ctx.getProtocol(KnownProtocolKind::ObjectiveCBridgeable)) {
26402640
SmallVector<ProtocolConformance *, 1> conformances;
2641-
if (nominal->lookupConformance(dc->getParentModule(),
2642-
objcBridgeable,
2643-
conformances))
2641+
if (nominal->lookupConformance(objcBridgeable, conformances))
26442642
break;
26452643
}
26462644
}

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;

0 commit comments

Comments
 (0)