Having purpose attached to the contextual type element makes it much
easier to diagnose contextual mismatches without involving constraint
system state.
This fixes the placement of the await fix-it inside of interpolated
strings. We were putting the effect between the `\` and `(`, which
doesn't exactly work out very well. I'm intentionally being relatively
gentle with the casting when grabbing the body of the interpolated
string.
I can't think of a valid expression that doesn't result in that
structure, so it's probably safe to do a straight cast, and probably
should switch it over eventually. In the current state-of-affairs, it
will put the fix-it placement in the wrong place if my assumptions are
broken about the structure of the code.
This patch restructures how we emit the effect errors for missing
awaits. As we're traversing the expressions, we collect all of the
locations where a missing await is, and metadata about the reason for
the error, as well as the "anchor".
The anchor is where the await should actually be placed in the
expression to fix things. The error is emitted for the whole
sub-expression instead of for the exact synchronization/call-site of the
async function. This avoids the erroneous message for
```
_ = 32 + asyncFunc()
```
The old behaviour was to put the `await` between the `+` operator and
the call to `asyncFunc()`, but this is not a valid place to put effects.
Note; this issue is also present in the fix-it for `try` insertions and
also needs to be fixed. Instead, the anchor points between the
assignment expression and 32, labelling the whole right-side of the
assignment as being the asynchronous function. We emit notes for each
uncovered async point in the entire expression though, so that someone
can see why the expression is async.
We need to be able to traverse back to the top of expressions in order
to emit the diagnostic to the right place. This patch records the parent
map of the highest expression in the tree that the checker was
constructed with. This will record the mapping for all sub-expressions
as well.
Actor inheritance was removed in the second revision of SE-0306. Remove
the ability to inherit actors.
Note that this doesn't fully eliminate all vestigates of inheritance
from actors. There are simplifications that need to be performed
still, e.g., there's no need to distinguish
designated/convenience/required initializers. That will follow.
This new attribute can be used on parameters of `@Sendable async` type
to indicate that the closures arguments passed to such parameters
should inherit the actor context where they are formed, which is not
the normal behavior for `@Sendable` closures.
Another part of rdar://76927008.
This check made this request depend on evaluation order, sometimes
synthesizing a second memberwise initializer if the previous one's
interface type had not been computed yet.
Add a new parameter attribute `@_implicitSelfCapture` that disables the
requirement to explicitly use `self.` to refer to a member of `self`
in an escaping closure.
Part of rdar://76927008.
There are a number of occurances that create implicit `Switch`s by passing `SourceLoc()` for all location paramters. Refactor those occurances out to a separate `createImplicit` method that automatically fills the locations with invalid source locations.
Destructors can't be run on the main actor since they may be called from
a asynchronous context. Because we are the only ones with a handle to
the class, we can touch Main-Actor protected properties from anywhere
safely. We can't touch static properties though since those will still
be alive and accessible from outside of just this dying instance.
`PreCheckExpression` already skips calls, make sure that invalid subscripts,
dynamic subscript, ObjC literals preserve paren/tuple for an index/argument.
Resolves: rdar://61749633
This saves us from needing to re-match args to params in CSApply and is also
useful for a forthcoming change migrating code completion in argument position
to use the solver-based typeCheckForCodeCompletion api.
rdar://76581093