File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -2642,7 +2642,9 @@ void PreCheckTarget::resolveKeyPathExpr(KeyPathExpr *KPE) {
26422642 if (isa<ParenExpr>(expr) || isa<TupleExpr>(expr)) {
26432643 DE.diagnose (expr->getLoc (),
26442644 diag::expr_string_interpolation_outside_string);
2645- } else {
2645+ } else if (!isa<ErrorExpr>(expr)) {
2646+ // If we have an `ErrorExpr`, we've probably already emitted a
2647+ // diagnostic explaining it.
26462648 DE.diagnose (expr->getLoc (),
26472649 diag::expr_swift_keypath_invalid_component);
26482650 }
Original file line number Diff line number Diff line change @@ -1186,8 +1186,7 @@ func f_56996() {
11861186 _ = \Int . byteSwapped. init ( ) // expected-error {{static member 'init()' cannot be used on instance of type 'Int'}}
11871187 _ = \Int // expected-error {{key path must have at least one component}}
11881188 _ = \Int ? // expected-error {{key path must have at least one component}}
1189- _ = \Int . // expected-error {{invalid component of Swift key path}}
1190- // expected-error@-1 {{expected member name following '.'}}
1189+ _ = \Int . // expected-error {{expected member name following '.'}}
11911190}
11921191
11931192// https://github.com/apple/swift/issues/55805
@@ -1439,4 +1438,4 @@ func testKeypathWithTypeReference() {
14391438 _ = \S . Q. Type. i // okay
14401439
14411440 _ = \S . Type. Q // expected-error {{key path cannot refer to type 'Q'}}
1442- }
1441+ }
You can’t perform that action at this time.
0 commit comments