Commit Graph

7 Commits

Author SHA1 Message Date
Luciano Almeida
7300fb5836 [Sema] Improve diagnostic for closure return contextual mismatch 2022-09-04 22:28:49 -03:00
Luciano Almeida
11877d7a1b [Sema][Revert] Revert CTP to CTP_ReturnStmt for closure result in return stmt 2022-07-15 09:31:11 -03:00
Luciano Almeida
44f4eba6c5 [Sema] Add return context valid source loc to implicit tuple expr context for diagnostic 2022-07-11 20:57:54 -03:00
Pavel Yaskevich
2750e69267 [CSSimplify] Inject .callAsFunction upon trailing closure mismatch
Detect that extraneous closure belongs to `.init` call on a callable
type and let the solver inject `.callAsFunction` before fixing it.

This prevents incorrect "extraneous trailing closure" diagnostic when
issue is located inside of the closure itself.
2022-06-14 11:41:27 -07:00
Pavel Yaskevich
ea4ac2c332 [CSSimplify] Fix trailing closure vs. defaulted parameter matching
If current parameter cannot accept a trailing closure, let's match
current closure argument to it only if there is absolutely no
possible other choice e.g. no other parameters (defaulted or not)
that could accept the closure via a less restrictive backward scan.
2022-06-14 11:41:19 -07:00
Pavel Yaskevich
d81007cf08 [CSSimplify] Avoid filtering init overloads of a callable type
If there is a call to `init` on a callable type that has a trailing
closure, let's avoid filtering because it's impossible to tell whether
a trailing closure belongs to an `init` call or implicit `.callAsFunction`
that would be attempted after it.

Resolves: rdar://92912878
2022-05-09 18:12:52 -07:00
Pavel Yaskevich
73e0670cc8 [TypeChecker] NFC: Add a couple of test-cases for .callAsFunction
Make sure that trailing closure(s) are correctly matched to injected
`.callAsFunction` when necessary i.e. constructor doesn't attempt
trailing closures but `.callAsFunction` does.
2022-02-03 15:36:19 -08:00