Closure result type or generic parameter associated with such a location
could bw inferred from a body of a multi-statement closure (when inference
is enabled), so we need to give closure a chance to run before attemtping
a hole for such positions in diagnostic mode.
When multi-statement closure inference is enabled it's body is
type-checked together with enclosing context, so they could be
walked directly just like single-expressions ones.
Propagate `LeaveClosureBodyUnchecked` flag from `typeCheckASTNodeAtLoc`
down to declaration checker to skip checking closures associated with
pattern binding entry initializers. This is no-op until multi-statement
inference becomes enabled by default.
While building a closure to inject `checkExpect` code, clone member
references associated with assignment. Re-using AST nodes is generally
invalid. This is visible with multi-statement closure inference enabled,
because the body is type-checked together with enclosing context
and both elements end up sharing `DeclRefExpr` and `MemberRefExpr`s.
Now that the CSApply just uses components, we can
better split up the key path constructors to either
accept a set of resolved components, or a parsed
root or path.
The logic here could form AST loops due to passing
in `anchor` for the key path's parsed path.
However setting a parsed path here seems to be a
holdover from the CSDiag days, so set the path to
`nullptr` and rip out and the rest of the synthesis
and SanitizeExpr logic for it.
rdar://85236369
...by using `__attribute__((swift_attr("@Sendable")))`. `@_nonSendable` will "beat" `@Sendable`, while `@_nonSendable(_assumed)` will not.
This commit also checks if `SwiftAttr` supports `#pragma clang attribute` and, if it does, defines `__SWIFT_ATTR_SUPPORTS_SENDABLE_DECLS` in imported headers so they know they can apply these attributes in an auditing style.
This logic cannot live in `ActorIsolationChecker` because
all of the relevant information is only accessible through
constraint system while applying solutions.
Use newly added `isDistributedThunk` check to determine whether
the given call is to a remote distributed actor and if so mark
it as implicitly throwing.
Resolves: rdar://83610106
Diagnostics cannot assume that solution would always be applied
to the constraint system, so all of the elements affected by the
mismatch have to be determined by the fix.
Resolves: rdar://85021348
While checking validity of the optional chain, let's not assume
that the contextual type associated with is optional because
enclosing expression could too be invalid.
Resolves: rdar://85166519
@IBAction calls are always delivered in the main thread, so reflect that
by inferring `@MainActor(unsafe)` for such methods whenever no other
actor isolation is provided.
Implements rdar://84474640.
One can overload on async vs. non-async, and the constraint solver has a
preference rule based on context. Extend that preference rule to
witness matching, so we prefer a witness that exactly matches the
effects of the requirement to one that has fewer effects.
Fixes rdar://84034057.
If a type variable has a subtype binding which came from a conversion/subtype/equality
constraint to a struct or enum (expect to `AnyHashable`, `Unsafe{Mutable}RawPointer`),
attempt it early because that type is the only choice which is not going to fail such
constraint.
For example, in cases like `$T argument convertible to Int` type variable could
only be bound to `Int`, `Int!`, or `@lvalue Int` to satisfy that constraint, so
it would make sense to attempt to bind it to `Int` early if it doesn't represent
a result of a member lookup (that's how IUO and/or `@lvalue` could be inferred)`
and doesn't have any direct disjunction associated with it e.g. for coercion or
optional matching.
When a closure has an isolated parameter, the closure itself is
isolated to that parameter. Capture this in the isolation of the
closure itself, so it is propagated to nested closures.
Fixes rdar://83733845.