[sourcekit] Fix assertion hit when doing cursor-info on a subscript parameter declaration.

Fixes rdar:/30060622
This commit is contained in:
Argyrios Kyrtzidis
2017-01-17 14:56:36 -08:00
parent 29b59342f8
commit da1328f04b
2 changed files with 9 additions and 0 deletions

View File

@@ -3,11 +3,17 @@ struct Person {
init(aName:String) {
self.name = aName
}
subscript(x: Int) -> Int {
return x
}
}
// rdar://24133008
// RUN: %sourcekitd-test -req=cursor -pos=4:16 %s -- %s | %FileCheck %s -check-prefix=CASE1
// RUN: %sourcekitd-test -req=cursor -pos=4:24 %s -- %s | %FileCheck %s -check-prefix=CASE2
// RUN: %sourcekitd-test -req=cursor -pos=7:15 %s -- %s | %FileCheck %s -check-prefix=CASE3
// CASE1: source.lang.swift.ref.var.instance (2:9-2:13)
// CASE2: source.lang.swift.ref.var.local (3:10-3:15)
// CASE3: source.lang.swift.decl.var.parameter (7:15-7:16)

View File

@@ -454,6 +454,9 @@ void walkRelatedDecls(const ValueDecl *VD, const FnTy &Fn) {
++NamesSeen[VD->getFullName()];
SmallVector<ValueDecl *, 8> RelatedDecls;
if (isa<ParamDecl>(VD))
return; // Parameters don't have interesting related declarations.
// FIXME: Extract useful related declarations, overloaded functions,
// if VD is an initializer, we should extract other initializers etc.
// For now we use UnqualifiedLookup to fetch other declarations with the same