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
6 changes: 3 additions & 3 deletions lib/Sema/PreCheckTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2531,11 +2531,11 @@ void PreCheckTarget::resolveKeyPathExpr(KeyPathExpr *KPE) {
(void)outermostExpr;
assert(OEE == outermostExpr);
expr = OEE->getSubExpr();
} else if (auto AE = dyn_cast<ApplyExpr>(expr)) {
} else if (auto CE = dyn_cast<CallExpr>(expr)) {
// foo(), foo(val value: Int) or unapplied foo
components.push_back(KeyPathExpr::Component::forUnresolvedApply(
getASTContext(), AE->getArgs()));
expr = AE->getFn();
getASTContext(), CE->getArgs()));
expr = CE->getFn();
} else {
if (emitErrors) {
// \(<expr>) may be an attempt to write a string interpolation outside
Expand Down
1 change: 0 additions & 1 deletion test/StringProcessing/Parse/forward-slash-regex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ _ = /\()/
// expected-error@-1 {{'/' is not a prefix unary operator}}
// expected-error@-2 {{'/' is not a postfix unary operator}}
// expected-error@-3 {{invalid component of Swift key path}}
// expected-error@-4 {{type of expression is ambiguous without a type annotation}}

do {
let _: Regex = (/whatever\)/
Expand Down
13 changes: 13 additions & 0 deletions test/expr/unary/keypath/keypath-unsupported-methods.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,16 @@ func f_56996() {
_ = \Int.byteSwapped.signum() // expected-error {{key path cannot refer to instance method 'signum()'}}
_ = \Int.byteSwapped.init() // expected-error {{key path cannot refer to initializer 'init()'}}
}

postfix operator ^
postfix func ^ <T>(_ x: T) -> T { x }

func unsupportedOperator() {
struct S {
var x: Int
}
_ = \.^ // expected-error {{invalid component of Swift key path}}
_ = \S^ // expected-error {{invalid component of Swift key path}}
_ = \S.x^ // expected-error {{invalid component of Swift key path}}
_ = \.x^ // expected-error {{invalid component of Swift key path}}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// {"signature":"(anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*)"}
// RUN: not --crash %target-swift-frontend -typecheck %s
// RUN: not %target-swift-frontend -typecheck %s
\.+=