Skip to content

Commit 0081b28

Browse files
authored
Merge pull request #83113 from hamishknight/walk-val
[AST] Visit TypeValueExpr's TypeRepr in ASTWalker
2 parents dbbdfce + 87f9820 commit 0081b28

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

lib/AST/ASTWalker.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,10 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
14611461
}
14621462

14631463
Expr *visitTypeValueExpr(TypeValueExpr *E) {
1464+
if (auto *TR = E->getRepr()) {
1465+
if (doIt(TR))
1466+
return nullptr;
1467+
}
14641468
return E;
14651469
}
14661470

test/Index/index_generic_params.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,16 @@ _ = C.Nested(value: 1)
165165
// CHECK-NEXT: [[@LINE+2]]:7 | struct/Swift | Nested | [[C_Nested_USR]] | Ref | rel: 0
166166
// CHECK-NEXT: [[@LINE+1]]:14 | constructor/Swift | init(value:) | [[C_Nested_init_USR]] | Ref,Call | rel: 0
167167
_ = C.Nested.init(value: 1)
168+
169+
// MARK: - Test value generic parameters
170+
171+
struct HasValueGenericParam<let Param: Int> {
172+
// CHECK: [[@LINE-1]]:33 | type-alias/generic-type-param/Swift | Param | s:14swift_ide_test20HasValueGenericParamV0G0xmfp | Def,RelChild | rel: 1
173+
// CHECK-NEXT: RelChild | struct/Swift | HasValueGenericParam
174+
func foo() {
175+
_ = Param
176+
// CHECK: [[@LINE-1]]:9 | type-alias/generic-type-param/Swift | Param | s:14swift_ide_test20HasValueGenericParamV0G0xmfp | Ref,RelCont | rel: 1
177+
// CHECK-NEXT: RelCont | instance-method/Swift | foo()
178+
}
179+
}
180+

test/SourceKit/CursorInfo/cursor_generics.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public protocol Proto<Assoc> {
3434
associatedtype Assoc
3535
}
3636

37+
struct HasValueGenericParam<let Param: Int> {
38+
func foo() {
39+
_ = Param
40+
}
41+
}
42+
3743
// RUN: %sourcekitd-test -req=cursor -pos=1:10 %s -- %s | %FileCheck -check-prefix=CHECK1 %s
3844
// CHECK1: <Declaration>func testGenerics&lt;T&gt;(x: <Type usr="s:15cursor_generics12testGenerics1xyx_tlF1TL_xmfp">T</Type>)</Declaration>
3945

@@ -69,3 +75,7 @@ public protocol Proto<Assoc> {
6975
// CHECK_ASSOC_COMMON-NEXT: source.refactoring.kind.rename.global
7076
// CHECK_ASSOC_COMMON-NEXT: Global Rename
7177
// CHECK_ASSOC_COMMON-NEXT: ACTIONS END
78+
79+
// RUN: %sourcekitd-test -req=cursor -pos=39:9 %s -- %s | %FileCheck -check-prefix=CHECK_VALUE_GENERIC %s
80+
// CHECK_VALUE_GENERIC: source.lang.swift.ref.generic_type_param (37:33-37:38)
81+
// CHECK_VALUE_GENERIC: <Declaration>let Param : <Type usr="s:Si">Int</Type></Declaration>

0 commit comments

Comments
 (0)