Skip to content

Commit 96414be

Browse files
committed
AST: Remove ProtocolDecl::getSuperclass()/setSuperclass()
1 parent 3626fb0 commit 96414be

File tree

4 files changed

+7
-44
lines changed

4 files changed

+7
-44
lines changed

include/swift/AST/Decl.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5217,16 +5217,10 @@ class ProtocolDecl final : public NominalTypeDecl {
52175217
/// Determine whether this protocol has a superclass.
52185218
bool hasSuperclass() const { return (bool)getSuperclassDecl(); }
52195219

5220-
/// Retrieve the superclass of this protocol, or null if there is no superclass.
5221-
Type getSuperclass() const;
5222-
52235220
/// Retrieve the ClassDecl for the superclass of this protocol, or null if there
52245221
/// is no superclass.
52255222
ClassDecl *getSuperclassDecl() const;
52265223

5227-
/// Set the superclass of this protocol.
5228-
void setSuperclass(Type superclass);
5229-
52305224
/// Retrieve the set of AssociatedTypeDecl members of this protocol; this
52315225
/// saves loading the set of members in cases where there's no possibility of
52325226
/// a protocol having nested types (ObjC protocols).

include/swift/AST/TypeCheckRequests.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class InheritedTypeRequest
113113
/// Request the superclass type for the given class.
114114
class SuperclassTypeRequest
115115
: public SimpleRequest<
116-
SuperclassTypeRequest, Type(NominalTypeDecl *, TypeResolutionStage),
116+
SuperclassTypeRequest, Type(ClassDecl *, TypeResolutionStage),
117117
RequestFlags::SeparatelyCached | RequestFlags::DependencySink> {
118118
public:
119119
using SimpleRequest::SimpleRequest;
@@ -123,7 +123,7 @@ class SuperclassTypeRequest
123123

124124
// Evaluation.
125125
Type
126-
evaluate(Evaluator &evaluator, NominalTypeDecl *classDecl,
126+
evaluate(Evaluator &evaluator, ClassDecl *classDecl,
127127
TypeResolutionStage stage) const;
128128

129129
public:

lib/AST/Decl.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6545,29 +6545,12 @@ AssociatedTypeDecl *ProtocolDecl::getAssociatedType(Identifier name) const {
65456545
return nullptr;
65466546
}
65476547

6548-
Type ProtocolDecl::getSuperclass() const {
6549-
ASTContext &ctx = getASTContext();
6550-
return evaluateOrDefault(ctx.evaluator,
6551-
SuperclassTypeRequest{const_cast<ProtocolDecl *>(this),
6552-
TypeResolutionStage::Interface},
6553-
Type());
6554-
}
6555-
65566548
ClassDecl *ProtocolDecl::getSuperclassDecl() const {
65576549
ASTContext &ctx = getASTContext();
65586550
return evaluateOrDefault(ctx.evaluator,
65596551
SuperclassDeclRequest{const_cast<ProtocolDecl *>(this)}, nullptr);
65606552
}
65616553

6562-
void ProtocolDecl::setSuperclass(Type superclass) {
6563-
assert((!superclass || !superclass->hasArchetype())
6564-
&& "superclass must be interface type");
6565-
LazySemanticInfo.SuperclassType.setPointerAndInt(superclass, true);
6566-
LazySemanticInfo.SuperclassDecl.setPointerAndInt(
6567-
superclass ? superclass->getClassOrBoundGenericClass() : nullptr,
6568-
true);
6569-
}
6570-
65716554
bool ProtocolDecl::walkInheritedProtocols(
65726555
llvm::function_ref<TypeWalker::Action(ProtocolDecl *)> fn) const {
65736556
auto self = const_cast<ProtocolDecl *>(this);

lib/Sema/TypeCheckRequestFunctions.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,14 @@ Type InheritedTypeRequest::evaluate(
8484

8585
Type
8686
SuperclassTypeRequest::evaluate(Evaluator &evaluator,
87-
NominalTypeDecl *nominalDecl,
87+
ClassDecl *classDecl,
8888
TypeResolutionStage stage) const {
89-
assert(isa<ClassDecl>(nominalDecl) || isa<ProtocolDecl>(nominalDecl));
90-
91-
// If this is a protocol that came from a serialized module, compute the
92-
// superclass via its generic signature.
93-
if (auto *proto = dyn_cast<ProtocolDecl>(nominalDecl)) {
94-
if (proto->wasDeserialized()) {
95-
return proto->getGenericSignature()
96-
->getSuperclassBound(proto->getSelfInterfaceType());
97-
}
98-
99-
if (!proto->getSuperclassDecl())
100-
return Type();
101-
} else if (auto classDecl = dyn_cast<ClassDecl>(nominalDecl)) {
102-
if (!classDecl->getSuperclassDecl())
103-
return Type();
104-
}
89+
if (!classDecl->getSuperclassDecl())
90+
return Type();
10591

106-
for (unsigned int idx : nominalDecl->getInherited().getIndices()) {
92+
for (unsigned int idx : classDecl->getInherited().getIndices()) {
10793
auto result = evaluateOrDefault(evaluator,
108-
InheritedTypeRequest{nominalDecl, idx, stage},
94+
InheritedTypeRequest{classDecl, idx, stage},
10995
Type());
11096
if (!result)
11197
continue;

0 commit comments

Comments
 (0)