File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
test/SourceKit/CursorInfo Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -174,7 +174,12 @@ class NodeFinder : ASTWalker {
174
174
}
175
175
176
176
PreWalkAction walkToDeclPre (Decl *D) override {
177
- if (!rangeContainsLocToResolve (D->getSourceRangeIncludingAttrs ())) {
177
+ // If the decl doesn't contain the location to resolve, we can skip walking
178
+ // it. One exception to this is for VarDecls, they can contain accessors
179
+ // which are not included in their SourceRange. For e.g `var x: Int { 0 }`,
180
+ // the VarDecl's range is just `x`, but the location may be in the accessor.
181
+ if (!isa<VarDecl>(D) &&
182
+ !rangeContainsLocToResolve (D->getSourceRangeIncludingAttrs ())) {
178
183
return Action::SkipNode ();
179
184
}
180
185
Original file line number Diff line number Diff line change
1
+ func foo( _ x: Int ) -> Int { }
2
+ func foo( _ x: String ) -> Int { }
3
+
4
+ // rdar://131135631 - Make sure we can resolve solver-based cursor info in a
5
+ // VarDecl's accessor.
6
+ var x : Int {
7
+ // RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):3 %s -- %s | %FileCheck %s
8
+ foo ( )
9
+ }
10
+
11
+ // CHECK-DAG: source.lang.swift.ref.function.free (1:6-1:19)
12
+ // CHECK-DAG: source.lang.swift.ref.function.free (2:6-2:22)
You can’t perform that action at this time.
0 commit comments