Skip to content

Commit cbe0afd

Browse files
authored
Merge pull request #61985 from bnbarham/index-use-original-args
[Index] Use original arguments for indexing memberwise init labels
2 parents 521a615 + 872001f commit cbe0afd

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

lib/Index/Index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
661661
LabelIndex++;
662662
}
663663
} else if (auto *CallParent = dyn_cast_or_null<CallExpr>(getParentExpr())) {
664-
auto *args = CallParent->getArgs();
664+
auto *args = CallParent->getArgs()->getOriginalArgs();
665665
Args.append(args->begin(), args->end());
666666
}
667667

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-ide-test -print-indexed-symbols -source-filename %s | %FileCheck %s
3+
4+
struct DefaultedStruct {
5+
var x = 17
6+
var y = true
7+
var z = "hello"
8+
}
9+
10+
// Make sure indexing uses the original arguments when adding references to
11+
// the properties in a memberwise initializer
12+
func useDefaultInits() {
13+
// CHECK-NOT: s:14swift_ide_test15DefaultedStructV1xSbvp
14+
// CHECK-NOT: s:14swift_ide_test15DefaultedStructV1zSbvp
15+
// CHECK: [[@LINE+2]]:23 | instance-property/Swift | y | s:14swift_ide_test15DefaultedStructV1ySbvp | Ref,RelCont
16+
// CHECK: [[@LINE+1]]:7 | constructor/Swift | init(x:y:z:) | s:14swift_ide_test15DefaultedStructV1x1y1zACSi_SbSStcfc | Ref,Call,RelCall,RelCont | rel: 1
17+
_ = DefaultedStruct(y: false)
18+
}
19+

test/Index/roles.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -474,19 +474,6 @@ _ = \StructWithKeypath.[0]
474474
// CHECK: [[@LINE-1]]:24 | instance-property/subscript/Swift | subscript(_:) | s:14swift_ide_test17StructWithKeypathVyS2icip | Ref,Read | rel: 0
475475
// CHECK: [[@LINE-2]]:24 | instance-method/acc-get/Swift | getter:subscript(_:) | s:14swift_ide_test17StructWithKeypathVyS2icig | Ref,Call,Impl | rel: 0
476476

477-
478-
struct BStruct {
479-
var x = 17
480-
var y = true
481-
var z = "hello"
482-
}
483-
484-
func useDefaultInits() {
485-
_ = BStruct(y: false)
486-
// CHECK: [[@LINE-1]]:15 | instance-property/Swift | y | s:14swift_ide_test7BStructV1ySbvp | Ref,RelCont
487-
// CHECK: [[@LINE-2]]:7 | constructor/Swift | init(x:y:z:) | s:14swift_ide_test7BStructV1x1y1zACSi_SbSStcfc | Ref,Call,RelCall,RelCont | rel: 1
488-
}
489-
490477
internal protocol FromInt {
491478
init(_ uint64: Int)
492479
}

0 commit comments

Comments
 (0)