Skip to content

Commit 71be544

Browse files
committed
[ASTPrinter] Add missing null check in isNonSendableExtension
The extended nominal may not be present for an invalid extension. rdar://149032713
1 parent a10356a commit 71be544

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,8 +2234,11 @@ bool isNonSendableExtension(const Decl *D) {
22342234
if (!ED || !ED->isUnavailable())
22352235
return false;
22362236

2237-
auto nonSendable =
2238-
ED->getExtendedNominal()->getAttrs().getEffectiveSendableAttr();
2237+
auto *NTD = ED->getExtendedNominal();
2238+
if (!NTD)
2239+
return false;
2240+
2241+
auto nonSendable = NTD->getAttrs().getEffectiveSendableAttr();
22392242
if (!isa_and_nonnull<NonSendableAttr>(nonSendable))
22402243
return false;
22412244

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %target-swift-ide-test -print-swift-file-interface -source-filename %s
2+
3+
@available(*, unavailable)
4+
extension Foo {}

0 commit comments

Comments
 (0)