Skip to content

Commit 1901862

Browse files
committed
AST: Remove LookUpConformanceInSignature
1 parent fae01d9 commit 1901862

File tree

16 files changed

+29
-73
lines changed

16 files changed

+29
-73
lines changed

include/swift/AST/GenericSignature.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,6 @@ class alignas(1 << TypeAlignInBits) GenericSignatureImpl final
322322
SmallVector<Requirement, 2> &reqs,
323323
SmallVector<InverseRequirement, 2> &inverses) const;
324324

325-
/// Look up a stored conformance in the generic signature. These are formed
326-
/// from same-type constraints placed on associated types of generic
327-
/// parameters which have conformance constraints on them.
328-
ProtocolConformanceRef lookupConformance(CanType depTy,
329-
ProtocolDecl *proto) const;
330-
331325
/// Iterate over all generic parameters, passing a flag to the callback
332326
/// indicating if the generic parameter is canonical or not.
333327
void forEachParam(

include/swift/AST/Type.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,6 @@ class MakeAbstractConformanceForGenericType {
114114
Type conformingReplacementType,
115115
ProtocolDecl *conformedProtocol) const;
116116
};
117-
118-
/// Functor class suitable for use as a \c LookupConformanceFn that fetches
119-
/// conformances from a generic signature.
120-
class LookUpConformanceInSignature {
121-
public:
122-
LookUpConformanceInSignature(const GenericSignatureImpl *Sig) {}
123-
124-
ProtocolConformanceRef operator()(CanType dependentType,
125-
Type conformingReplacementType,
126-
ProtocolDecl *conformedProtocol) const;
127-
};
128117

129118
/// Flags that can be passed when substituting into a type.
130119
enum class SubstFlags {

lib/AST/ASTDemangler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ Type ASTBuilder::createSILBoxTypeWithLayout(
953953
if (signature)
954954
substs = createSubstitutionMapFromGenericArgs(
955955
signature, replacements,
956-
LookUpConformanceInSignature(signature.getPointer()));
956+
LookUpConformanceInModule());
957957
return SILBoxType::get(Ctx, layout, substs);
958958
}
959959

@@ -1052,7 +1052,7 @@ SubstitutionMap
10521052
ASTBuilder::createSubstitutionMap(BuiltGenericSignature sig,
10531053
ArrayRef<BuiltType> replacements) {
10541054
return SubstitutionMap::get(sig, replacements,
1055-
LookUpConformanceInSignature(sig.getPointer()));
1055+
LookUpConformanceInModule());
10561056
}
10571057

10581058
Type ASTBuilder::subst(Type subject, const BuiltSubstitutionMap &Subs) const {

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7128,7 +7128,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
71287128
}
71297129
llvm_unreachable("ran out of type parameters");
71307130
return Type();
7131-
}, LookUpConformanceInSignature(sig.getPointer()));
7131+
}, LookUpConformanceInModule());
71327132
}
71337133

71347134
void visitElementArchetypeType(ElementArchetypeType *T) {

lib/AST/GenericEnvironment.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,6 @@ auto GenericEnvironment::getOrCreateNestedTypeStorage() -> NestedTypeStorage & {
452452
Type
453453
GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
454454
auto genericSig = getGenericSignature();
455-
LookUpConformanceInSignature conformanceLookupFn(genericSig.getPointer());
456-
457455
auto requirements = genericSig->getLocalRequirements(depType);
458456

459457
/// Substitute a type for the purpose of requirements.
@@ -462,7 +460,7 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
462460
case Kind::Primary:
463461
case Kind::OpenedExistential:
464462
if (type->hasTypeParameter()) {
465-
return mapTypeIntoContext(type, conformanceLookupFn);
463+
return mapTypeIntoContext(type, LookUpConformanceInModule());
466464
} else {
467465
return type;
468466
}
@@ -643,8 +641,7 @@ Type GenericEnvironment::mapTypeIntoContext(
643641
}
644642

645643
Type GenericEnvironment::mapTypeIntoContext(Type type) const {
646-
auto sig = getGenericSignature();
647-
return mapTypeIntoContext(type, LookUpConformanceInSignature(sig.getPointer()));
644+
return mapTypeIntoContext(type, LookUpConformanceInModule());
648645
}
649646

650647
Type GenericEnvironment::mapTypeIntoContext(GenericTypeParamType *type) const {
@@ -769,7 +766,7 @@ GenericEnvironment::mapElementTypeIntoPackContext(Type type) const {
769766
}
770767
return mapIntoContext(genericParam);
771768
},
772-
LookUpConformanceInSignature(sig.getPointer()),
769+
LookUpConformanceInModule(),
773770
SubstFlags::PreservePackExpansionLevel);
774771
}
775772

@@ -825,7 +822,7 @@ GenericEnvironment::mapConformanceRefIntoContext(
825822
ProtocolConformanceRef conformance) const {
826823
auto contextConformance = conformance.subst(conformingInterfaceType,
827824
QueryInterfaceTypeSubstitutions(this),
828-
LookUpConformanceInSignature(getGenericSignature().getPointer()));
825+
LookUpConformanceInModule());
829826

830827
auto contextType = mapTypeIntoContext(conformingInterfaceType);
831828
return {contextType, contextConformance};

lib/AST/GenericSignature.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -340,18 +340,6 @@ ASTContext &GenericSignatureImpl::getASTContext() const {
340340
return GenericSignature::getASTContext(getGenericParams(), getRequirements());
341341
}
342342

343-
ProtocolConformanceRef
344-
GenericSignatureImpl::lookupConformance(CanType type,
345-
ProtocolDecl *proto) const {
346-
// FIXME: Actually implement this properly.
347-
auto *M = proto->getParentModule();
348-
349-
if (type->isTypeParameter())
350-
return ProtocolConformanceRef(proto);
351-
352-
return M->lookupConformance(type, proto, /*allowMissing=*/true);
353-
}
354-
355343
bool GenericSignatureImpl::requiresClass(Type type) const {
356344
assert(type->isTypeParameter() &&
357345
"Only type parameters can have superclass requirements");
@@ -430,7 +418,7 @@ bool GenericSignatureImpl::isRequirementSatisfied(
430418

431419
return type;
432420
},
433-
LookUpConformanceInSignature(this));
421+
LookUpConformanceInModule());
434422
}
435423

436424
SmallVector<Requirement, 2> subReqs;

lib/AST/RequirementMachine/GenericSignatureQueries.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static Type substPrefixType(Type type, unsigned suffixLength, Type prefixType,
349349
auto substBaseType = substPrefixType(memberType->getBase(), suffixLength - 1,
350350
prefixType, sig);
351351
return memberType->substBaseType(
352-
substBaseType, LookUpConformanceInSignature(sig.getPointer()),
352+
substBaseType, LookUpConformanceInModule(),
353353
std::nullopt);
354354
}
355355

lib/AST/TypeSubstitution.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -261,17 +261,6 @@ operator()(CanType dependentType, Type conformingReplacementType,
261261
return ProtocolConformanceRef(conformedProtocol);
262262
}
263263

264-
ProtocolConformanceRef LookUpConformanceInSignature::
265-
operator()(CanType dependentType, Type conformingReplacementType,
266-
ProtocolDecl *conformedProtocol) const {
267-
if (conformingReplacementType->isTypeParameter())
268-
return ProtocolConformanceRef(conformedProtocol);
269-
270-
return ModuleDecl::lookupConformance(
271-
conformingReplacementType->getCanonicalType(),
272-
conformedProtocol, /*allowMissing=*/true);
273-
}
274-
275264
Type DependentMemberType::substBaseType(Type substBase) {
276265
return substBaseType(substBase, LookUpConformanceInModule(),
277266
std::nullopt);

lib/IRGen/GenMeta.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2692,7 +2692,7 @@ namespace {
26922692
auto sig = genericEnv->getGenericSignature();
26932693
underlyingConformance = underlyingConformance.subst(
26942694
underlyingType, QueryInterfaceTypeSubstitutions(genericEnv),
2695-
LookUpConformanceInSignature(sig.getPointer()));
2695+
LookUpConformanceInModule());
26962696

26972697
underlyingType = genericEnv->mapTypeIntoContext(underlyingType)
26982698
->getCanonicalType();

lib/IRGen/GenPack.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,10 @@ static void bindElementSignatureRequirementsAtIndex(
352352
patternPackArchetype)
353353
->getCanonicalType();
354354
llvm::Value *_metadata = nullptr;
355-
auto packConformance =
356-
context.signature->lookupConformance(ty, proto);
355+
auto packConformance = ProtocolConformanceRef(proto);
357356
auto *wtablePack = emitWitnessTableRef(IGF, patternPackArchetype,
358357
&_metadata, packConformance);
359-
auto elementConformance =
360-
context.signature->lookupConformance(ty, proto);
358+
auto elementConformance = ProtocolConformanceRef(proto);
361359
auto *wtable = bindWitnessTableAtIndex(
362360
IGF, elementArchetype, elementConformance, wtablePack, index);
363361
assert(wtable);
@@ -574,7 +572,7 @@ static llvm::Value *emitPackExpansionElementWitnessTable(
574572
auto instantiatedPatternTy =
575573
context.environment->mapContextualPackTypeIntoElementContext(patternTy);
576574
auto instantiatedConformance =
577-
context.environment->getGenericSignature()->lookupConformance(
575+
ModuleDecl::lookupConformance(
578576
instantiatedPatternTy, conformance.getRequirement());
579577

580578
// Emit the element witness table.

0 commit comments

Comments
 (0)