Skip to content

Commit c777e5a

Browse files
committed
[NFC] non-null assertion for inheritsFrom
1 parent a2defd5 commit c777e5a

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

lib/AST/Decl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6558,6 +6558,8 @@ bool ProtocolDecl::walkInheritedProtocols(
65586558
}
65596559

65606560
bool ProtocolDecl::inheritsFrom(const ProtocolDecl *super) const {
6561+
assert(super);
6562+
65616563
if (this == super)
65626564
return false;
65636565

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ bool IsActorRequest::evaluate(
165165
if (auto protocol = dyn_cast<ProtocolDecl>(nominal)) {
166166
auto &ctx = protocol->getASTContext();
167167
auto *actorProtocol = ctx.getProtocol(KnownProtocolKind::Actor);
168+
if (!actorProtocol)
169+
return false;
170+
168171
return (protocol == actorProtocol ||
169172
protocol->inheritsFrom(actorProtocol));
170173
}

lib/Sema/TypeCheckDistributed.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ bool IsDistributedActorRequest::evaluate(
188188
if (auto protocol = dyn_cast<ProtocolDecl>(nominal)) {
189189
auto &ctx = protocol->getASTContext();
190190
auto *distributedActorProtocol = ctx.getDistributedActorDecl();
191+
if (!distributedActorProtocol)
192+
return false;
193+
191194
return (protocol == distributedActorProtocol ||
192195
protocol->inheritsFrom(distributedActorProtocol));
193196
}

0 commit comments

Comments
 (0)