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) {
125125 bool IsExtension = false ;
126126
127127 if (auto *VD = dyn_cast<ValueDecl>(D)) {
128- if (VD-> hasName () && !VD->isImplicit ()) {
128+ if (!VD->isImplicit ()) {
129129 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+ }
133137 }
134138
135139 auto ReportParamList = [&](ParameterList *PL) {
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ func foo() {
1919 var local = 5
2020}
2121
22+ let `else` = 3
23+
2224// RUN: %sourcekitd-test -req=collect-var-type %s -- %s | %FileCheck %s
2325// CHECK: (1:5, 1:6): Int (explicit type: 1)
2426// CHECK: (2:5, 2:6): String (explicit type: 0)
@@ -30,3 +32,4 @@ func foo() {
3032// CHECK: (14:7, 14:8): [Int : Int] (explicit type: 1)
3133// CHECK: (15:7, 15:8): (Int) -> Int (explicit type: 1)
3234// 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
88 param. count
99}
1010
11+ let w : ( String , Int ) -> Void = { ( _, x) in }
12+
1113// RUN: %sourcekitd-test -req=collect-var-type %s -- %s | %FileCheck %s
1214// CHECK: (1:10, 1:15): Int (explicit type: 1)
1315// CHECK: (5:5, 5:6): (String) -> Void (explicit type: 1)
1416// CHECK: (5:29, 5:34): String (explicit type: 0)
1517// CHECK: (7:5, 7:6): (String) -> Int (explicit type: 0)
1618// 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