Skip to content

[NFC] Remove Unused Module Parameter to Conformance Lookup #38753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3227,16 +3227,13 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
/// Look for conformances of this nominal type to the given
/// protocol.
///
/// \param module The module from which we initiate the search.
/// FIXME: This is currently unused.
///
/// \param protocol The protocol whose conformance is requested.
/// \param conformances Will be populated with the set of protocol
/// conformances found for this protocol.
///
/// \returns true if any conformances were found.
bool lookupConformance(
ModuleDecl *module, ProtocolDecl *protocol,
ProtocolDecl *protocol,
SmallVectorImpl<ProtocolConformance *> &conformances) const;

/// Retrieve all of the protocols that this nominal type conforms to.
Expand Down
1 change: 0 additions & 1 deletion lib/AST/ConformanceLookupTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,6 @@ void ConformanceLookupTable::registerProtocolConformance(
}

bool ConformanceLookupTable::lookupConformance(
ModuleDecl *module,
NominalTypeDecl *nominal,
ProtocolDecl *protocol,
SmallVectorImpl<ProtocolConformance *> &conformances) {
Expand Down
3 changes: 1 addition & 2 deletions lib/AST/ConformanceLookupTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,7 @@ class ConformanceLookupTable {
/// conformances found for this protocol and nominal type.
///
/// \returns true if any conformances were found.
bool lookupConformance(ModuleDecl *module,
NominalTypeDecl *nominal,
bool lookupConformance(NominalTypeDecl *nominal,
ProtocolDecl *protocol,
SmallVectorImpl<ProtocolConformance *> &conformances);

Expand Down
2 changes: 1 addition & 1 deletion lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3129,7 +3129,7 @@ bool ValueDecl::canInferObjCFromRequirement(ValueDecl *requirement) {
// If the nominal type doesn't conform to the protocol at all, we
// cannot infer @objc no matter what we do.
SmallVector<ProtocolConformance *, 1> conformances;
if (!nominal->lookupConformance(getModuleContext(), proto, conformances))
if (!nominal->lookupConformance(proto, conformances))
return false;

// If any of the conformances is attributed to the context in which
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ LookupConformanceInModuleRequest::evaluate(

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

Expand Down
3 changes: 1 addition & 2 deletions lib/AST/ProtocolConformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,11 +1284,10 @@ void NominalTypeDecl::prepareConformanceTable() const {
}

bool NominalTypeDecl::lookupConformance(
ModuleDecl *module, ProtocolDecl *protocol,
ProtocolDecl *protocol,
SmallVectorImpl<ProtocolConformance *> &conformances) const {
prepareConformanceTable();
return ConformanceTable->lookupConformance(
module,
const_cast<NominalTypeDecl *>(this),
protocol,
conformances);
Expand Down
4 changes: 1 addition & 3 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2638,9 +2638,7 @@ getForeignRepresentable(Type type, ForeignLanguage language,
if (auto objcBridgeable
= ctx.getProtocol(KnownProtocolKind::ObjectiveCBridgeable)) {
SmallVector<ProtocolConformance *, 1> conformances;
if (nominal->lookupConformance(dc->getParentModule(),
objcBridgeable,
conformances))
if (nominal->lookupConformance(objcBridgeable, conformances))
break;
}
}
Expand Down
6 changes: 2 additions & 4 deletions lib/ClangImporter/ImportType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,7 @@ namespace {
auto nominal = element->getAnyNominal();
auto simdscalar = Impl.SwiftContext.getProtocol(KnownProtocolKind::SIMDScalar);
SmallVector<ProtocolConformance *, 2> conformances;
if (simdscalar && nominal->lookupConformance(nominal->getParentModule(),
simdscalar, conformances)) {
if (simdscalar && nominal->lookupConformance(simdscalar, conformances)) {
// Element type conforms to SIMDScalar. Get the SIMDn generic type
// if it exists.
SmallString<8> name("SIMD");
Expand Down Expand Up @@ -2807,8 +2806,7 @@ bool ClangImporter::Implementation::matchesHashableBound(Type type) {
auto hashable = SwiftContext.getProtocol(KnownProtocolKind::Hashable);
SmallVector<ProtocolConformance *, 2> conformances;
return hashable &&
nominal->lookupConformance(nominal->getParentModule(), hashable,
conformances);
nominal->lookupConformance(hashable, conformances);
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/ModuleInterfaceSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ class InheritedProtocolCollector {
const NominalTypeDecl *nominal,
ProtocolDecl *proto) {
SmallVector<ProtocolConformance *, 4> conformances;
nominal->lookupConformance(M, proto, conformances);
nominal->lookupConformance(proto, conformances);
return llvm::all_of(conformances,
[M](const ProtocolConformance *conformance) -> bool {
return M == conformance->getDeclContext()->getParentModule();
Expand Down
2 changes: 1 addition & 1 deletion lib/IDE/CodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4349,7 +4349,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
// Check for conformance to the literal protocol.
if (auto *NTD = T->getAnyNominal()) {
SmallVector<ProtocolConformance *, 2> conformances;
if (NTD->lookupConformance(CurrModule, P, conformances)) {
if (NTD->lookupConformance(P, conformances)) {
addTypeAnnotation(builder, T);
builder.setExpectedTypeRelation(typeRelation);
return;
Expand Down
2 changes: 1 addition & 1 deletion lib/PrintAsObjC/DeclAndTypePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ class DeclAndTypePrinter::Implementation

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

// Dig out the Objective-C type.
Expand Down
2 changes: 1 addition & 1 deletion lib/PrintAsObjC/ModuleContentsWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class ModuleWriter {

SmallVector<ProtocolConformance *, 1> conformances;
auto errorTypeProto = ctx.getProtocol(KnownProtocolKind::Error);
if (ED->lookupConformance(&M, errorTypeProto, conformances)) {
if (ED->lookupConformance(errorTypeProto, conformances)) {
bool hasDomainCase = std::any_of(ED->getAllElements().begin(),
ED->getAllElements().end(),
[](const EnumElementDecl *elem) {
Expand Down
3 changes: 1 addition & 2 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7035,8 +7035,7 @@ allFromConditionalConformances(DeclContext *DC, Type baseTy,

if (auto *protocol = candidateDC->getSelfProtocolDecl()) {
SmallVector<ProtocolConformance *, 4> conformances;
if (!NTD->lookupConformance(DC->getParentModule(), protocol,
conformances))
if (!NTD->lookupConformance(protocol, conformances))
return false;

// This is opportunistic, there should be a way to narrow the
Expand Down
1 change: 0 additions & 1 deletion lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5801,7 +5801,6 @@ bool TypeVarBindingProducer::requiresOptionalAdjustment(
if (auto *nominalBindingDecl = type->getAnyNominal()) {
SmallVector<ProtocolConformance *, 2> conformances;
conformsToExprByNilLiteral = nominalBindingDecl->lookupConformance(
CS.DC->getParentModule(),
CS.getASTContext().getProtocol(
KnownProtocolKind::ExpressibleByNilLiteral),
conformances);
Expand Down
3 changes: 1 addition & 2 deletions lib/Sema/PreCheckExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2043,8 +2043,7 @@ Expr *PreCheckExpression::simplifyTypeConstructionWithLiteralArg(Expr *E) {
}

SmallVector<ProtocolConformance *, 2> conformances;
return castTy->getAnyNominal()->lookupConformance(DC->getParentModule(),
protocol, conformances)
return castTy->getAnyNominal()->lookupConformance(protocol, conformances)
? CoerceExpr::forLiteralInit(getASTContext(), argExpr,
call->getSourceRange(),
typeExpr->getTypeRepr())
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2910,7 +2910,7 @@ void AttributeChecker::visitImplementsAttr(ImplementsAttr *attr) {
// conforms to the specified protocol.
NominalTypeDecl *NTD = DC->getSelfNominalTypeDecl();
SmallVector<ProtocolConformance *, 2> conformances;
if (!NTD->lookupConformance(DC->getParentModule(), PD, conformances)) {
if (!NTD->lookupConformance(PD, conformances)) {
diagnose(attr->getLocation(),
diag::implements_attr_protocol_not_conformed_to,
NTD->getName(), PD->getName())
Expand Down
3 changes: 1 addition & 2 deletions lib/Sema/TypeCheckProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6221,8 +6221,7 @@ swift::findWitnessedObjCRequirements(const ValueDecl *witness,
// Dig out the conformance.
if (!conformance.hasValue()) {
SmallVector<ProtocolConformance *, 2> conformances;
nominal->lookupConformance(dc->getParentModule(), proto,
conformances);
nominal->lookupConformance(proto, conformances);
if (conformances.size() == 1)
conformance = conformances.front();
else
Expand Down
3 changes: 1 addition & 2 deletions lib/Sema/TypeCheckStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ static void tryDiagnoseUnnecessaryCastOverOptionSet(ASTContext &Ctx,
if (!optionSetType)
return;
SmallVector<ProtocolConformance *, 4> conformances;
if (!(optionSetType &&
NTD->lookupConformance(module, optionSetType, conformances)))
if (!(optionSetType && NTD->lookupConformance(optionSetType, conformances)))
return;

auto *CE = dyn_cast<CallExpr>(E);
Expand Down
6 changes: 2 additions & 4 deletions lib/Sema/TypeCheckStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ static void computeLoweredStoredProperties(NominalTypeDecl *decl) {

if (auto actorProto = ctx.getProtocol(KnownProtocolKind::Actor)) {
SmallVector<ProtocolConformance *, 1> conformances;
classDecl->lookupConformance(
decl->getModuleContext(), actorProto, conformances);
classDecl->lookupConformance(actorProto, conformances);
for (auto conformance : conformances)
TypeChecker::checkConformance(conformance->getRootNormalConformance());
}
Expand All @@ -138,8 +137,7 @@ static void computeLoweredStoredProperties(NominalTypeDecl *decl) {
if (classDecl->isDistributedActor()) {
if (auto actorProto = ctx.getProtocol(KnownProtocolKind::DistributedActor)) {
SmallVector<ProtocolConformance *, 1> conformances;
classDecl->lookupConformance(
decl->getModuleContext(), actorProto, conformances);
classDecl->lookupConformance(actorProto, conformances);
for (auto conformance : conformances)
TypeChecker::checkConformance(conformance->getRootNormalConformance());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Serialization/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ ModuleFile::readConformanceChecked(llvm::BitstreamCursor &Cursor,
module = getAssociatedModule();

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