Skip to content

Commit e089f2a

Browse files
authored
Merge pull request #19938 from rockbruno/swift-keypath-index
[Index] Fully index Swift Keypaths referencing @objc properties
2 parents d20fdf5 + 32c5935 commit e089f2a

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/AST/ASTWalker.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,6 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
972972
Expr *sub = doIt(objcStringLiteral);
973973
if (!sub) return nullptr;
974974
E->setObjCStringLiteralExpr(sub);
975-
return E;
976975
}
977976

978977
auto components = E->getComponents();

test/Index/index_keypaths.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %target-swift-ide-test -print-indexed-symbols -source-filename %s | %FileCheck %s
2+
// REQUIRES: objc_interop
3+
4+
struct MyStruct {
5+
struct Inner {
6+
let myProp = 1
7+
}
8+
}
9+
10+
class MyClass {
11+
class Inner {
12+
@objc var myProp = 1
13+
}
14+
}
15+
16+
let a = \MyStruct.Inner.myProp
17+
// CHECK: [[@LINE-1]]:25 | {{.*}} | myProp
18+
// CHECK: [[@LINE-2]]:10 | {{.*}} | MyStruct
19+
// CHECK: [[@LINE-3]]:19 | {{.*}} | Inner
20+
let b: KeyPath<MyStruct.Inner, Int> = \.myProp
21+
// CHECK: [[@LINE-1]]:41 | {{.*}} | myProp
22+
let c = \MyClass.Inner.myProp
23+
// CHECK: [[@LINE-1]]:24 | {{.*}} | myProp
24+
// CHECK: [[@LINE-2]]:10 | {{.*}} | MyClass
25+
// CHECK: [[@LINE-3]]:18 | {{.*}} | Inner
26+
let d: KeyPath<MyClass.Inner, Int> = \.myProp
27+
// CHECK: [[@LINE-1]]:40 | {{.*}} | myProp

0 commit comments

Comments
 (0)