Skip to content

Commit 247dda9

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 bc07600 commit 247dda9

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
@@ -2235,8 +2235,11 @@ bool isNonSendableExtension(const Decl *D) {
22352235
if (!ED || !ED->isUnavailable())
22362236
return false;
22372237

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

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)