The Fix-It was adding @unsafe prior to the extension, which is
incorrect. Make sure we apply @unsafe at the right location for the
explicit conformance.
Fixes rdar://151800162
This code is no longer used given that region isolation is always enabled
along with strict concurrency checking.
(cherry picked from commit c283ce12d5)
Check for unsafe constructs in all modes, so that we can emit the
"unsafe does not cover any unsafe constructs" warning consistently.
One does not need to write "unsafe" outside of strict memory safety
mode, but if you do... it needs to cover unsafe behavior.
(cherry picked from commit 1b94c3b3d6)
This feature is essentially self-migrating, but fit it into the
migration flow by marking it as migratable, adding
`-strict-memory-safety:migrate`, and introducing a test.
(cherry picked from commit abad2fae0f)
When migrating, provide warnings that add 'nonisolated' to nonisolated
conformances that don't already have it and would end up being inferred
to be isolated under the upcoming feature.
(cherry picked from commit a32782bcbc)
When issuing warnings about an import not needing to be public, we did
not account for the Distributed module MUST be imported when a
distributed actor is declared. This also actually means that a public
distributed actor effectively is a public use of the DistributedActor
protocol
resolves rdar://152129980
Omit an explicit access level from `MemberImportVisibility` fix-its under the
following conditions:
- `InternalImportsByDefault` is enabled.
- The required import needs an `internal` access level or lower.
- The module is not yet imported explicitly in any other file.
Resolves rdar://149577615.
`@unchecked Sendble` is dangerous, and almost always the wrong thing to
use. Don't have the compiler suggest it.
(cherry picked from commit a922e8e356)
Replaces generic `expression is 'async' but is not marked with 'await`
diagnostic with a tailed one for cases where there is an access to an
actor-isolated value outside of its actor without `await` keyword.
This makes the diagnostics for async and sync contexts consistent
and actually identifies a problem instead of simply pointing out
the solution.
Resolves: rdar://151720646
(cherry picked from commit 7a6ba8e8c58c58b3438f31fec06102d02bae81a5)
SILGen expects actor instance isolation to always come from captures,
we need to maintain that with implicit isolation capture performed by
`@_inheritActorContext(always)`.
(cherry picked from commit 91047446ad)
- Extend `@_inheritActorContext` attribute to support optional `always` modifier.
The new modifier will make closure context isolated even if the parameter is not
captured by the closure.
- Implementation `@_inheritActorContext` attribute validation - it could only be
used on parameter that have `@Sendable` or `sending` and `@isolated(any)` or
`async` function type (downgraded to a warning until future major Swift mode
to avoid source compatibility issues).
- Add a new language feature that guards use of `@_inheritActorContext(always)` in swift interface files
- Update `getLoweredLocalCaptures` to add an entry for isolation parameter implicitly captured by `@_inheritActorContext(always)`
- Update serialization code to store `always` modifier
(cherry picked from commit 04d46760bb)
(cherry picked from commit c050e8f75a)
(cherry picked from commit c0aca5384b)
(cherry picked from commit a4f6d710cf)
(cherry picked from commit 6c911f5d42)
(cherry picked from commit 17b8f7ef12)
Using IncludeTree::FileList to concat the include tree file systems that
are passed on the command-line. This significantly reduce the
command-line size, and also makes the cache key computation a lot
faster.
rdar://148752988
(cherry picked from commit 201e4faea7)
When the attribute is specified explicitly passing a `@concurrent`
closure to a global actor-isolated parameter or contextual type
should result in a conversion and closure itself should be nonisolated.
Resolves: rdar://151797372
(cherry picked from commit efc6efc4ed)
When an "unsafe" expression is used as the case expression, lift it up
so it also covers the synthesized matching expression (`=~`). This
eliminates some unsuppressible strict memory safety warnings.
Fixes rdar://151731850.
See the inline comments for more details. Depending on the closure's
type signature, sometimes adding the attribute will break code. Fix this
by also adding inferred effects to the signature in these cases.
(cherry picked from commit 2d7e040d4d)
`@MainActor` errors are hard errors, even in minimal concurrency checking in Swift 5 mode.
When users set the default isolation to main actor, we should infer `@preconcurrency @MainActor`
in language modes < 6 to get the right diagnostic staging behavior.
Resolves: rdar://151029517
(cherry picked from commit 6561476059)
Perform `Sendable` checking on parameter/result of the function
type when conversion between asynchroneous functions results in
a loss of global actor isolation attribute because access would
result in data crossing an isolation boundary.
This is a warning until Swift language mode 6.
Resolves: rdar://130168104
(cherry picked from commit a058ffc998)
The diagnostic can outlive the locally constructed attribute, which was
passed by pointer, if there is an active `DiagnosticTransaction`.
(cherry picked from commit f4e49d5a0a)
This broke when we split `@execution(...)` into `@concurrent` and
`nonisolated(nonsending)` because the latter became its own `TypeRepr`,
whereas the condition for whether to attempt migration diagnostics
inside `resolveASTFunctionType` is still based on the function type's
attributes alone.
(cherry picked from commit bee2b6778e)
Introduction of `@concurrent` attribute caused an unintended
side-effect in `ClosureEffectsRequest` since the attribute
could only be used on `async` types setting `async` too early
prevented body analysis for `throws` from running.
Resolves: rdar://151421590
(cherry picked from commit cda9866b26)
Skipping type-checking the body when the preamble fails to type-check
seems to be more of a historical artifact than intentional behavior.
Certain elements of the body may still get type-checked through
request evaluation, and as such may introduce autoclosures that won't
be properly contextualized.
Make sure we continue type-checking the body even if the preamble
fails. We already invalidate any variables bound in the element
pattern, so downstream type-checking should be able to handle it
just fine. This ensures autoclosures get contextualized, and that
we're still able to provide semantic diagnostics for other issues in
the body.
rdar://136500008
There's a synthesized call to unsafeBitCast(_:to:), which is obvious
unsafe, and is being diagnosed as such. The compiler generates this
call, so have the compiler also generate the `unsafe` around it to
suppress these warnings.
Fixes rdar://151199011.
While building an initializer call the declaration reference
should have the same implicitness as the call when it doesn't
require thunking, otherwise don't attempt to mark autoclosures
as non-implicit because it could break assumptions elsewhere.
(cherry picked from commit 37e2f374aa)
Per SE-0411, we compute the isolation of a default value expression
based on what isolation it requires. Include isolated conformance
checks in this computation, rather than always emitting diagnostics,
so that the combination of isolated default values + isolated
conformances works as expected.
Fixes rdar://150691429.