Skip to content

Commit 43e7043

Browse files
authored
Merge pull request #6889 from akyrtzi/fix-cursor-assertion-subscript-param-3.1
[sourcekit] Fix assertion hit when doing cursor-info on a subscript parameter declaration.
2 parents 8695b19 + 0e847a0 commit 43e7043

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

test/SourceKit/CursorInfo/crash1.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ struct Person {
33
init(aName:String) {
44
self.name = aName
55
}
6+
7+
subscript(x: Int) -> Int {
8+
return x
9+
}
610
}
711

812
// rdar://24133008
913
// RUN: %sourcekitd-test -req=cursor -pos=4:16 %s -- %s | %FileCheck %s -check-prefix=CASE1
1014
// RUN: %sourcekitd-test -req=cursor -pos=4:24 %s -- %s | %FileCheck %s -check-prefix=CASE2
15+
// RUN: %sourcekitd-test -req=cursor -pos=7:15 %s -- %s | %FileCheck %s -check-prefix=CASE3
1116

1217
// CASE1: source.lang.swift.ref.var.instance (2:9-2:13)
1318
// CASE2: source.lang.swift.ref.var.local (3:10-3:15)
19+
// CASE3: source.lang.swift.decl.var.parameter (7:15-7:16)

tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ void walkRelatedDecls(const ValueDecl *VD, const FnTy &Fn) {
454454
++NamesSeen[VD->getFullName()];
455455
SmallVector<ValueDecl *, 8> RelatedDecls;
456456

457+
if (isa<ParamDecl>(VD))
458+
return; // Parameters don't have interesting related declarations.
459+
457460
// FIXME: Extract useful related declarations, overloaded functions,
458461
// if VD is an initializer, we should extract other initializers etc.
459462
// For now we use UnqualifiedLookup to fetch other declarations with the same

0 commit comments

Comments
 (0)