Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Sema/PreCheckTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2642,7 +2642,9 @@ void PreCheckTarget::resolveKeyPathExpr(KeyPathExpr *KPE) {
if (isa<ParenExpr>(expr) || isa<TupleExpr>(expr)) {
DE.diagnose(expr->getLoc(),
diag::expr_string_interpolation_outside_string);
} else {
} else if (!isa<ErrorExpr>(expr)) {
// If we have an `ErrorExpr`, we've probably already emitted a
// diagnostic explaining it.
DE.diagnose(expr->getLoc(),
diag::expr_swift_keypath_invalid_component);
}
Expand Down
5 changes: 2 additions & 3 deletions test/expr/unary/keypath/keypath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1186,8 +1186,7 @@ func f_56996() {
_ = \Int.byteSwapped.init() // expected-error {{static member 'init()' cannot be used on instance of type 'Int'}}
_ = \Int // expected-error {{key path must have at least one component}}
_ = \Int? // expected-error {{key path must have at least one component}}
_ = \Int. // expected-error {{invalid component of Swift key path}}
// expected-error@-1 {{expected member name following '.'}}
_ = \Int. // expected-error {{expected member name following '.'}}
}

// https://github.com/apple/swift/issues/55805
Expand Down Expand Up @@ -1439,4 +1438,4 @@ func testKeypathWithTypeReference() {
_ = \S.Q.Type.i // okay

_ = \S.Type.Q // expected-error {{key path cannot refer to type 'Q'}}
}
}