From cf52f78baa0cbac219ca6928a4dc4997b04b4f6f Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Wed, 21 Sep 2022 10:03:19 -0600 Subject: [PATCH] don't use null types when determining extension access level rdar://100169094 Co-Authored-By: Max Obermeier --- lib/SymbolGraphGen/Symbol.cpp | 8 +++++--- .../CursorInfo/cursor_symbol_graph_extensions.swift | 13 +++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 test/SourceKit/CursorInfo/cursor_symbol_graph_extensions.swift diff --git a/lib/SymbolGraphGen/Symbol.cpp b/lib/SymbolGraphGen/Symbol.cpp index 471f9287b1ca7..6306adcfe20da 100644 --- a/lib/SymbolGraphGen/Symbol.cpp +++ b/lib/SymbolGraphGen/Symbol.cpp @@ -801,9 +801,11 @@ AccessLevel Symbol::getEffectiveAccessLevel(const ExtensionDecl *ED) { AccessLevel maxInheritedAL = AccessLevel::Private; for (auto Inherited : ED->getInherited()) { - if (const auto *Proto = dyn_cast_or_null( - Inherited.getType()->getAnyNominal())) { - maxInheritedAL = std::max(maxInheritedAL, Proto->getFormalAccess()); + if (const auto Type = Inherited.getType()) { + if (const auto *Proto = dyn_cast_or_null( + Type->getAnyNominal())) { + maxInheritedAL = std::max(maxInheritedAL, Proto->getFormalAccess()); + } } } diff --git a/test/SourceKit/CursorInfo/cursor_symbol_graph_extensions.swift b/test/SourceKit/CursorInfo/cursor_symbol_graph_extensions.swift new file mode 100644 index 0000000000000..67f8d67311bb4 --- /dev/null +++ b/test/SourceKit/CursorInfo/cursor_symbol_graph_extensions.swift @@ -0,0 +1,13 @@ +// RUN: %sourcekitd-test -req=cursor -pos=9:28 -req-opts=retrieve_symbol_graph=1 %s -- %s + +extension ResourceRecordType { + public var debugDescription: String { + public struct HostRecord { + } + extension HostRecord: Hashable { + public struct StartOfAuthorityRecord { + public var a + } + } + } +}