Introduce a marker protocol SendableMetatype that is used to indicate
when the metatype of a type will conform to Sendable. Specifically,
`T: SendableMetatype` implies `T.Type: Sendable`. When strict
metatype sendability is enabled, metatypes are only sendable when `T:
SendableMetatype`.
All nominal types implicitly conform to `SendableMetatype`, as do the
various builtin types, function types, etc. The `Sendable` marker
protocol now inherits from `SendableMetatype`, so that `T: Sendable`
implies `T.Type: Sendable`.
Thank you Slava for the excellent idea!
I am doing this b/c we are going to ban borrowing sending so that we can leave
open that space for further design. In the short term, we need the ability to
create +0 sending parameters without messing with mangling. By special casing
this, we get what we want.
rdar://129116141
At the type that I introduced type throws into AsyncSequence and its
algorithms, I accidentally dropped a `@preconcurrency` on the ABI
entrypoint, leading to a mangled name change.
Fixes rdar://123639030.
This couples together several changes to move entirely from
`@rethrows` over to typed throws:
* Use the `Failure` type to determine whether an async for-each loop
will throw, rather than depending on rethrows checking
* Introduce a special carve-out for `rethrows` functions that have a
generic requirement on an `AsyncSequence` or `AsyncIteratorProtocol`,
which uses that requirement's `Failure` type as potentially being part
of the thrown error type. This allows existing generic functions like
the following to continue to work:
func f<S: AsyncSequence>(_: S) rethrows
* Switch SIL generation for the async for-each loop from the prior
`next()` over to the typed-throws version `_nextElement`.
* Remove `@rethrows` from `AsyncSequence` and `AsyncIteratorProtocol`
entirely. We are now fully dependent on typed throws.
Introduce a new associated type `Failure` into the two protocols involved
in async sequences, which represents the type thrown when the sequence
fails. Introduce a defaulted `_nextElement()` operations that throws
`Failure` or produces the next element of the sequence. Provide a
default implementation of `_nextElement()` in terms of `next()` that
force-cases the thrown error to the `Failure` type.
Introduce special associated type inference logic for the `Failure`
type of an `AsyncIteratorProtocol` conformance when there is no
specific _nextElement()` witness. This inference logic looks at the
witness for `next()`:
* If `next()` throws nothing, `Failure` is inferred to `Never`.
* If `next()` throws, `Failure` is inferred to `any Error`.
* If `next()` rethrows, `Failure` is inferred to `T.Failure`, where
`T` is the first type parameter with a conformance to either
`AsyncSequence` or `AsyncIteratorProtocol`.
The default implementation and the inference rule, together, allow
existing async sequences to continue working as before, and set us up
for changing the contract of the `async for` loop to use
`_nextIterator()` rather than `next()`.
Give `AsyncSequence` and `AsyncIteratorProtocol` primary associated
types for the element and failure types, which will allow them to be
used more generally with existential and opaque types.
All compilers that must be able to compile the standard library's textual
interface accept the following:
- back deployed functions declared without `@available`
- `@inlinable` back deployed functions
- `defer` blocks in back deployed functions
We can therefore revert the workarounds added in
https://github.com/apple/swift/pull/62946/ and
https://github.com/apple/swift/pull/62928/.
Resolves rdar://104085810
We shouldn't diagnose adding @_predatesConcurrency without considering the context because the attribute itself is for ABI-preserving purposes.
rdar://90738915
Adding `_runAsyncMain` to the api-digester list since we're adding
`@preconcurrency` when we add `@Sendable`. These two should negate each
other, but the api-digester isn't quite smart enough to understand that.
* Audit and correct AsyncSequence Sendability
* Annotate availability on Sendable conformances for AsyncSequences
* Fix typo of Sendable.Iterator
* Correct tests to use sendable builders
* Add @preconcurrency annotations and fixup one remaining missing @Sendable case
* Move preconcurrency to correct syntactical position
* Use unchecked Sendable conditional conformance instead of marking all internals as preconcurrency and sendable
* Use unchecked Sendable conditional conformance instead of marking all internals as preconcurrency and sendable for dropWhile
* claim ABI changes for marking of @preconcurrency as expected
Asynchronous functions isolated to global actors hop to the global at
the beginning of the function but do not hop back on return. For
`MainActor.run`, this means that we would not "hop back" off the main
actor after executing the closure, which lead to too much code running
on the main thread. Dropping the "async" ensures that we hop back.
While we my also want the general "hop back" semantics for
asynchronous actor-isolated functions, for now this addresses the
problem with `MainActor.run`.
Fixes rdar://82138050.
Add the generated ABI baseline for the _Concurency model on x86_64
macOS, along with a test that checks the built _Concurrency model
against that baseline.
Right now, the test is a mess, because we have some ABI breaks to
unwind. Add it so the test passes, and then we'll audit and address
every change.
Fixes rdar://83673282.