Skip to content

Commit 731f584

Browse files
committed
Address review feedback on AbstractConformance in ProtocolConformanceRef
1 parent 2a7de1b commit 731f584

37 files changed

+83
-81
lines changed

include/swift/AST/ASTBridgingImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ BridgedASTType BridgedConformance::getType() const {
602602
}
603603

604604
BridgedDeclObj BridgedConformance::getRequirement() const {
605-
return {unbridged().getRequirement()};
605+
return {unbridged().getProtocol()};
606606
}
607607

608608
BridgedConformance BridgedConformance::getGenericConformance() const {

include/swift/AST/ProtocolConformanceRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ class ProtocolConformanceRef {
179179
}
180180

181181
/// Retrieve the conforming type.
182-
Type getConformingType() const;
182+
Type getType() const;
183183

184184
/// Return the protocol requirement.
185-
ProtocolDecl *getRequirement() const;
185+
ProtocolDecl *getProtocol() const;
186186

187187
/// Apply a substitution to the conforming type.
188188
ProtocolConformanceRef subst(Type origType, SubstitutionMap subMap,

lib/APIDigester/ModuleAnalyzerNodes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, ImportDecl *ID):
14981498
}
14991499

15001500
SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, ProtocolConformanceRef Conform):
1501-
SDKNodeInitInfo(Ctx, Conform.getRequirement()) {
1501+
SDKNodeInitInfo(Ctx, Conform.getProtocol()) {
15021502
// The conformance can be conditional. The generic signature keeps track of
15031503
// the requirements.
15041504
if (Conform.isConcrete()) {

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5109,7 +5109,7 @@ void SILFunctionType::Profile(
51095109
invocationSubs.profile(id);
51105110
id.AddBoolean((bool)conformance);
51115111
if (conformance)
5112-
id.AddPointer(conformance.getRequirement());
5112+
id.AddPointer(conformance.getProtocol());
51135113
}
51145114

51155115
SILFunctionType::SILFunctionType(

lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5519,7 +5519,7 @@ class PrintConformance : public PrintBase {
55195519
assert(conformance.isAbstract());
55205520

55215521
printHead("abstract_conformance", ASTNodeColor, label);
5522-
printReferencedDeclField(conformance.getRequirement(),
5522+
printReferencedDeclField(conformance.getProtocol(),
55235523
Label::always("protocol"));
55245524
printFoot();
55255525
}

lib/AST/ASTMangler.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,7 @@ void ASTMangler::appendRetroactiveConformances(SubstitutionMap subMap,
21702170
if (conformance.isInvalid())
21712171
continue;
21722172

2173-
if (conformance.getRequirement()->isMarkerProtocol())
2173+
if (conformance.getProtocol()->isMarkerProtocol())
21742174
continue;
21752175

21762176
SWIFT_DEFER {
@@ -4528,7 +4528,7 @@ void ASTMangler::appendAnyProtocolConformance(
45284528
// If we have a conformance to a marker protocol but we aren't allowed to
45294529
// emit marker protocols, skip it.
45304530
if (!AllowMarkerProtocols &&
4531-
conformance.getRequirement()->isMarkerProtocol())
4531+
conformance.getProtocol()->isMarkerProtocol())
45324532
return;
45334533

45344534
// While all invertible protocols are marker protocols, do not mangle them
@@ -4537,15 +4537,17 @@ void ASTMangler::appendAnyProtocolConformance(
45374537
// but we *might* have let that slip by for the other cases below, so the
45384538
// early-exits are highly conservative.
45394539
const bool forInvertible =
4540-
conformance.getRequirement()->getInvertibleProtocolKind().has_value();
4540+
conformance.getProtocol()->getInvertibleProtocolKind().has_value();
45414541

45424542
if (conformingType->isTypeParameter()) {
45434543
assert(genericSig && "Need a generic signature to resolve conformance");
45444544
if (forInvertible)
45454545
return;
45464546

4547+
// FIXME: conformingType parameter should no longer be needed, because
4548+
// its in conformance.
45474549
auto path = genericSig->getConformancePath(conformingType,
4548-
conformance.getRequirement());
4550+
conformance.getProtocol());
45494551
appendDependentProtocolConformance(path, genericSig);
45504552
} else if (auto opaqueType = conformingType->getAs<OpaqueTypeArchetypeType>()) {
45514553
if (forInvertible)
@@ -4556,7 +4558,7 @@ void ASTMangler::appendAnyProtocolConformance(
45564558
ConformancePath conformancePath =
45574559
opaqueSignature->getConformancePath(
45584560
opaqueType->getInterfaceType(),
4559-
conformance.getRequirement());
4561+
conformance.getProtocol());
45604562

45614563
// Append the conformance path with the signature of the opaque type.
45624564
appendDependentProtocolConformance(conformancePath, opaqueSignature);

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6634,7 +6634,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
66346634
case SILFunctionType::Representation::WitnessMethod:
66356635
Printer << "witness_method: ";
66366636
printTypeDeclName(
6637-
witnessMethodConformance.getRequirement()->getDeclaredType()
6637+
witnessMethodConformance.getProtocol()->getDeclaredType()
66386638
->castTo<ProtocolType>());
66396639
break;
66406640
case SILFunctionType::Representation::Closure:

lib/AST/ASTVerifier.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,7 +1785,7 @@ class Verifier : public ASTWalker {
17851785
for (auto proto : erasedLayout.getProtocols()) {
17861786
if (std::find_if(conformances.begin(), conformances.end(),
17871787
[&](ProtocolConformanceRef ref) -> bool {
1788-
return ref.getRequirement() == proto->getDecl();
1788+
return ref.getProtocol() == proto->getDecl();
17891789
})
17901790
== conformances.end()) {
17911791
Out << "ErasureExpr is missing conformance for required protocol\n";
@@ -1819,7 +1819,7 @@ class Verifier : public ASTWalker {
18191819
anyHashableDecl->getDeclaredInterfaceType(),
18201820
"AnyHashableErasureExpr and the standard AnyHashable type");
18211821

1822-
if (E->getConformance().getRequirement() != hashableDecl) {
1822+
if (E->getConformance().getProtocol() != hashableDecl) {
18231823
Out << "conformance on AnyHashableErasureExpr was not for Hashable\n";
18241824
E->getConformance().dump(Out);
18251825
abort();
@@ -2811,7 +2811,7 @@ class Verifier : public ASTWalker {
28112811
if (!type->is<ArchetypeType>() && !type->isAnyExistentialType()) {
28122812
Out << "type " << type
28132813
<< " should not have an abstract conformance to "
2814-
<< conformance.getRequirement()->getName();
2814+
<< conformance.getProtocol()->getName();
28152815
abort();
28162816
}
28172817

lib/AST/AbstractConformance.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ class AbstractConformance final : public llvm::FoldingSetNode {
2929
AbstractConformance(Type conformingType, ProtocolDecl *requirement)
3030
: conformingType(conformingType), requirement(requirement) { }
3131

32-
Type getConformingType() const { return conformingType; }
33-
ProtocolDecl *getRequirement() const { return requirement; }
32+
Type getType() const { return conformingType; }
33+
ProtocolDecl *getProtocol() const { return requirement; }
3434

3535
void Profile(llvm::FoldingSetNodeID &id) const {
36-
Profile(id, getConformingType(), getRequirement());
36+
Profile(id, getType(), getProtocol());
3737
}
3838

3939
/// Profile the substitution map storage, for use with LLVM's FoldingSet.

lib/AST/Effects.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void swift::simple_display(llvm::raw_ostream &out,
136136

137137
bool ProtocolConformanceRef::hasEffect(EffectKind kind) const {
138138
if (!isConcrete()) { return kind != EffectKind::Unsafe; }
139-
return evaluateOrDefault(getRequirement()->getASTContext().evaluator,
139+
return evaluateOrDefault(getProtocol()->getASTContext().evaluator,
140140
ConformanceHasEffectRequest{kind, getConcrete()},
141141
true);
142142
}

0 commit comments

Comments
 (0)