File tree Expand file tree Collapse file tree 4 files changed +25
-4
lines changed
test/SourceKit/VariableType Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -125,11 +125,15 @@ bool SemaAnnotator::walkToDeclPre(Decl *D) {
125
125
bool IsExtension = false ;
126
126
127
127
if (auto *VD = dyn_cast<ValueDecl>(D)) {
128
- if (VD-> hasName () && !VD->isImplicit ()) {
128
+ if (!VD->isImplicit ()) {
129
129
SourceManager &SM = VD->getASTContext ().SourceMgr ;
130
- NameLen = VD->getBaseName ().userFacingName ().size ();
131
- if (Loc.isValid () && SM.extractText ({Loc, 1 }) == " `" )
132
- NameLen += 2 ;
130
+ if (VD->hasName ()) {
131
+ NameLen = VD->getBaseName ().userFacingName ().size ();
132
+ if (Loc.isValid () && SM.extractText ({Loc, 1 }) == " `" )
133
+ NameLen += 2 ;
134
+ } else if (Loc.isValid () && SM.extractText ({Loc, 1 }) == " _" ) {
135
+ NameLen = 1 ;
136
+ }
133
137
}
134
138
135
139
auto ReportParamList = [&](ParameterList *PL) {
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ func foo() {
19
19
var local = 5
20
20
}
21
21
22
+ let `else` = 3
23
+
22
24
// RUN: %sourcekitd-test -req=collect-var-type %s -- %s | %FileCheck %s
23
25
// CHECK: (1:5, 1:6): Int (explicit type: 1)
24
26
// CHECK: (2:5, 2:6): String (explicit type: 0)
@@ -30,3 +32,4 @@ func foo() {
30
32
// CHECK: (14:7, 14:8): [Int : Int] (explicit type: 1)
31
33
// CHECK: (15:7, 15:8): (Int) -> Int (explicit type: 1)
32
34
// CHECK: (19:7, 19:12): Int (explicit type: 0)
35
+ // CHECK: (22:5, 22:11): Int (explicit type: 0)
Original file line number Diff line number Diff line change @@ -8,9 +8,13 @@ let z = { (param: String) in
8
8
param. count
9
9
}
10
10
11
+ let w : ( String , Int ) -> Void = { ( _, x) in }
12
+
11
13
// RUN: %sourcekitd-test -req=collect-var-type %s -- %s | %FileCheck %s
12
14
// CHECK: (1:10, 1:15): Int (explicit type: 1)
13
15
// CHECK: (5:5, 5:6): (String) -> Void (explicit type: 1)
14
16
// CHECK: (5:29, 5:34): String (explicit type: 0)
15
17
// CHECK: (7:5, 7:6): (String) -> Int (explicit type: 0)
16
18
// CHECK: (7:12, 7:17): String (explicit type: 1)
19
+ // CHECK: (11:35, 11:36): String (explicit type: 0)
20
+ // CHECK: (11:38, 11:39): Int (explicit type: 0)
Original file line number Diff line number Diff line change
1
+ let = 2
2
+ let : Int = 4
3
+
4
+ let x : ( String ) -> Void = { ( : String ) in }
5
+
6
+ // RUN: %sourcekitd-test -req=collect-var-type %s -- %s | %FileCheck %s
7
+ // CHECK: <VariableTypes>
8
+ // CHECK-NEXT: (4:5, 4:6): (String) -> Void (explicit type: 1)
9
+ // CHECK-NEXT: </VariableTypes>
10
+
You can’t perform that action at this time.
0 commit comments