Skip to content

Commit 9def053

Browse files
authored
Merge pull request #37128 from ahoppen/pr/crash-invalid-extenshion-symbol-graph
[SymbolGraph] Fix a crash for member in invalid extension
2 parents 7be0429 + 370128e commit 9def053

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/SymbolGraphGen/SymbolGraph.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ void SymbolGraph::recordMemberRelationship(Symbol S) {
240240
if (isRequirementOrDefaultImplementation(S.getSymbolDecl())) {
241241
return;
242242
}
243+
if (DC->getSelfNominalTypeDecl() == nullptr) {
244+
// If we couldn't look up the type the member is declared on (e.g.
245+
// because the member is declared in an extension whose extended type
246+
// doesn't exist), don't record a memberOf relationship.
247+
return;
248+
}
243249
return recordEdge(S,
244250
Symbol(this, DC->getSelfNominalTypeDecl(), nullptr),
245251
RelationshipKind::MemberOf());
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %sourcekitd-test -req=cursor -pos=3:9 -req-opts=retrieve_symbol_graph=1 %s -- %s
2+
extension NonExistentSymbolName {
3+
var myType: String {
4+
""
5+
}
6+
}

0 commit comments

Comments
 (0)