File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
test/SourceKit/ExpressionType Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -667,6 +667,15 @@ class ExpressionTypeCollector: public SourceEntityWalker {
667
667
if (E->getType ().isNull ())
668
668
return false ;
669
669
670
+ // We should not report a type for implicit expressions, except for
671
+ // - `OptionalEvaluationExpr` to show the correct type when there is optional chaining
672
+ // - `DotSyntaxCallExpr` to report the method type without the metatype
673
+ if (E->isImplicit () &&
674
+ !isa<OptionalEvaluationExpr>(E) &&
675
+ !isa<DotSyntaxCallExpr>(E)) {
676
+ return false ;
677
+ }
678
+
670
679
// If we have already reported types for this source range, we shouldn't
671
680
// report again. This makes sure we always report the outtermost type of
672
681
// several overlapping expressions.
Original file line number Diff line number Diff line change @@ -20,6 +20,13 @@ func DictS(_ a: [Int: S]) {
20
20
_ = a [ 2 ] ? . val. advanced ( by: 1 ) . byteSwapped
21
21
}
22
22
23
+ func optExpr( str: String ? ) -> String ? {
24
+ let a : String ? = str
25
+ let b : String ? = " Hey "
26
+ let c : String = " Bye "
27
+ return c
28
+ }
29
+
23
30
// RUN: %sourcekitd-test -req=collect-type %s -- %s | %FileCheck %s
24
31
// CHECK: (183, 202): Int
25
32
// CHECK: (183, 196): String
@@ -31,3 +38,7 @@ func DictS(_ a: [Int: S]) {
31
38
// CHECK: (291, 292): Int?
32
39
// CHECK: (295, 332): Int?
33
40
// CHECK: (295, 320): Int
41
+ // CHECK: (395, 398): String?
42
+ // CHECK: (418, 423): String
43
+ // CHECK: (442, 447): String
44
+ // CHECK: (457, 458): String
You can’t perform that action at this time.
0 commit comments