Unify with `CTP_ReturnStmt`, and have the
SyntacticElementTarget carry the ReturnStmt for
regular type-checking, which we can use to record
implied returns.
Remove this bit from function decls and closures.
Instead, for closures, infer it from the presence
of a single return or single expression AST node
in the body, which ought to be equivalent, and
automatically takes result builders into
consideration. We can also completely drop this
query from AbstractFunctionDecl, replacing it
instead with a bit on ReturnStmt.
The old TypeAttributes reprsentation wasn't too bad for a small number of
simple attributes. Unfortunately, the number of attributes has grown over
the years by quite a bit, which makes TypeAttributes fairly bulky even at
just a single SourceLoc per attribute. The bigger problem is that we want
to carry more information than that on some of these attributes, which is
all super ad hoc and awkward. And given that we want to do some things
for each attribute we see, like diagnosing unapplied attributes, the linear
data structure does require a fair amount of extra work.
I switched around the checking logic quite a bit in order to try to fit in
with the new representation better. The most significant change here is the
change to how we handle implicit noescape, where now we're passing the
escaping attribute's presence down in the context instead of resetting the
context anytime we see any attributes at all. This should be cleaner overall.
The source range changes around some of the @escaping checking is really a
sort of bugfix --- the existing code was really jumping from the @ sign
all the way past the autoclosure keyword in a way that I'm not sure always
works and is definitely a little unintentional-feeling.
I tried to make the parser logic more consistent around recognizing these
parameter specifiers; it seems better now, at least.
Remove keypath subtype asserts; always use cached root type
Add tests for keypaths converted to funcs with inout param
Add unit test for overload selection
Instead of passing a unique_ptr of an opaque type back and forth,
let's just push elements onto an std::vector. For now this change
is completely NFC, but further simplifications will become
possible shortly.
Produce a tailored diagnostic that omits a fully unresolved key path
type (`KeyPath<_, _>`) when key path without an explicit root type is
passed as an argument to non-keypath parameter type (i.e. `Int`).
We were allowing the catch-all "X is not compatible with generics yet"
diagnostic to be emitted when there's a failure to satisfy a requirement
for a conditional Copyable conformance. Instead, allow the existing
infrastructure to diagnose such failures-to-conform to emit a diagnostic
.
This patch also adds a check to catch future catch-all diagnostics in
asserts builds, since I'd like to phase out that diagnostic when
NoncopyableGenerics is enabled.
Applying generic arguments to a variadic generic type uses the
PackMatcher to build a mapping between generic parameters and
arguments.
The PackMatcher is symmetric, so there was an unexpected failure
mode that wasn't handled: if the variadic generic type had some
non-pack parameters, but the argument list was a single pack
expansion type, the match would succeed, grouping all of the
generic parameters into a single match.
This is non-sensical, so we need to explicitly check for this
case and diagnose it. This requires a new diagnostic, since
otherwise the general diagnostic we emit for variadic generic
type mismatches doesn't make sense, since it's complaining
about there being too few generic parameters.
Fixes rdar://116713961 / https://github.com/apple/swift/issues/69012.