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 {
667667 if (E->getType ().isNull ())
668668 return false ;
669669
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+
670679 // If we have already reported types for this source range, we shouldn't
671680 // report again. This makes sure we always report the outtermost type of
672681 // several overlapping expressions.
Original file line number Diff line number Diff line change @@ -20,6 +20,13 @@ func DictS(_ a: [Int: S]) {
2020 _ = a [ 2 ] ? . val. advanced ( by: 1 ) . byteSwapped
2121}
2222
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+
2330// RUN: %sourcekitd-test -req=collect-type %s -- %s | %FileCheck %s
2431// CHECK: (183, 202): Int
2532// CHECK: (183, 196): String
@@ -31,3 +38,7 @@ func DictS(_ a: [Int: S]) {
3138// CHECK: (291, 292): Int?
3239// CHECK: (295, 332): Int?
3340// 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