chore(deps): update dependency apple/swift to v6 #555
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
5.10.1
->6.0.3
Release Notes
apple/swift (apple/swift)
v6.0.3
: Swift 6.0.3 ReleaseCompare Source
v6.0.2
: Swift 6.0.2 ReleaseCompare Source
v6.0.1
: Swift 6.0.1 ReleaseCompare Source
v6.0
Compare Source
2024-09-17 (Xcode 16.0)
Swift 6 comes with a new language mode that prevents the risk of data races
at compile time. This guarantee is accomplished through data isolation; the
compiler will validate that data passed over a boundary between concurrently
executing code is either safe to reference concurrently, or mutually
exclusive access to the value is enforced.
The data-race safety checks were previously available in Swift 5.10 through
the
-strict-concurrency=complete
compiler flag. Complete concurrencychecking in Swift 5.10 was overly restrictive, and Swift 6 removes many
false-positive data-race warnings through better
Sendable
inference,new analysis that proves mutually exclusive access when passing values with
non-
Sendable
type over isolation boundaries, and more.You can enable the Swift 6 language mode using the
-swift-version 6
compiler flag.
[SE-0428][]:
Distributed actors now have the ability to support complete split server /
client systems, thanks to the new
@Resolvable
macro and runtime changes.It is now possible to share an "API module" between a client and server
application, declare a resolvable distributed actor protocol with the expected
API contract and perform calls on it, without knowing the specific type the
server is implementing those actors as.
Declaring such protocol looks like this:
And the module structure to support such applications looks like this:
[SE-0424][]:
Serial executor gains a new customization point
checkIsolation()
, which can beimplemented by custom executor implementations in order to provide a last resort
check before the isolation asserting APIs such as
Actor.assumeIsolated
orassertIsolated
fail and crash.This specifically enables Dispatch to implement more sophisticated isolation
checking, and now even an actor which is "on a queue which is targeting
another specific queue" can be properly detected using these APIs.
Closures can now appear in pack expansion expressions, which allows you to
construct a parameter pack of closures where each closure captures the
corresponding element of some other parameter pack. For example:
[SE-0431][]:
You can now require a function value to carry its actor isolation
dynamically in a way that can be directly read by clients:
The isolation can read with the
.isolation
property, which has type(any Actor)?
:This capability has been adopted by the task-creation APIs in the
standard library. As a result, creating a task with an actor-isolated
function will now synchronously enqueue the task on the actor, which
can be used for transitive event-ordering guarantees if the actor
guarantees that jobs will be run in the order they are enqueued, as
@MainActor
does. If the function is not explicitly isolated, Swiftstill retains the right to optimize enqueues for functions that actually
start by doing work with different isolation from their formal isolation.
[SE-0423][]:
You can now use
@preconcurrency
attribute to replace static actor isolationchecking with dynamic checks for witnesses of synchronous nonisolated protocol
requirements when the witness is isolated. This is common when Swift programs
need to interoperate with frameworks written in C/C++/Objective-C whose
implementations cannot participate in static data race safety.
It's now possible for a
@MainActor
-isolated type to conform toViewDelegateProtocol
by marking conformance declaration as@preconcurrency
:The compiler would emit dynamic checks into the
respondToUIEvent()
witnessto make sure that it's always executed in
@MainActor
isolated context.Additionally, the compiler would emit dynamic actor isolation checks for:
@objc
thunks of synchronous actor-isolated members of classes.Synchronous actor-isolated function values passed to APIs that
erase actor isolation and haven't yet adopted strict concurrency checking.
Call-sites of synchronous actor-isolated functions imported from Swift 6 libraries.
The dynamic actor isolation checks can be disabled using the flag
-disable-dynamic-actor-isolation
.[SE-0420][]:
async
functions can now explicitly inherit the isolation of their callerby declaring an
isolated
parameter with the default value of#isolation
:When the caller is actor-isolated, this allows it to pass isolated state
to the function, which would otherwise have concurrency problems. The
function may also be able to eliminate unwanted scheduling changes, such
as when it can quickly return in a fast path without needing to suspend.
[SE-0418][]:
The compiler would now automatically employ
Sendable
on functionsand key path literal expressions that cannot capture non-Sendable values.
This includes partially-applied and unapplied instance methods of
Sendable
types, as well as non-local functions. Additionally, it is now disallowed
to utilize
@Sendable
on instance methods of non-Sendable types.Let's use the following type to illustrate the new inference rules:
Key path
\User.name
would be inferred asWritableKeyPath<User, String> & Sendable
because it doesn't capture any non-Sendable values.
The same applies to keypath-as-function conversions:
A function value produced by an un-applied reference to
getAge
would be marked as
@Sendable
becauseUser
is aSendable
struct:[SE-0432][]:
Noncopyable enums can be pattern-matched with switches without consuming the
value you switch over:
[SE-0429][]:
The noncopyable fields of certain types can now be consumed individually:
[SE-0430][]:
Region Based Isolation is now extended to enable the application of an
explicit
sending
annotation to function parameters and results. A functionparameter or result that is annotated with
sending
is required to bedisconnected at the function boundary and thus possesses the capability of
being safely sent across an isolation domain or merged into an actor-isolated
region in the function's body or the function's caller respectively. Example:
[SE-0414][]:
The compiler is now capable of determining whether or not a value that does
not conform to the
Sendable
protocol can safely be sent over an isolationboundary. This is done by introducing the concept of isolation regions that
allows the compiler to reason conservatively if two values can affect each
other. Through the usage of isolation regions, the compiler can now prove that
sending a value that does not conform to the
Sendable
protocol over anisolation boundary cannot result in races because the value (and any other
value that might reference it) is not used in the caller after the point of
sending allowing code like the following to compile:
[SE-0427][]:
You can now suppress
Copyable
on protocols, generic parameters,and existentials:
By writing
~Copyable
on a generic type, you're suppressing a defaultCopyable
constraint that would otherwise appear on that type. This permitsnoncopyable types, which have no
Copyable
conformance, to conform to suchprotocols and be substituted for those generic types. Full functionality of this
feature requires the newer Swift 6 runtime.
Since its introduction in Swift 5.1 the @TaskLocal property wrapper was used to
create and access task-local value bindings. Property wrappers introduce mutable storage,
which was now properly flagged as potential source of concurrency unsafety.
In order for Swift 6 language mode to not flag task-locals as potentially thread-unsafe,
task locals are now implemented using a macro. The macro has the same general semantics
and usage patterns, however there are two source-break situations which the Swift 6
task locals cannot handle:
Using an implicit default
nil
value for task local initialization, when combined with a type alias:At the same time, task locals can now be declared as global properties, which wasn't possible before.
Swift 5.10 missed a semantic check from [SE-0309][]. In type context, a reference to a
protocol
P
that has associated types orSelf
requirements should usethe
any
keyword, but this was not enforced in nested generic argument positions.This is now an error as required by the proposal:
To correct the error, add
any
where appropriate, for exampleOuter<any P>.Inner<any P>
.Swift 5.10 accepted certain invalid opaque return types from [SE-0346][].
If a generic argument of a constrained opaque return type did not
satisfy the requirements on the primary associated type, the generic
argument was silently ignored and type checking would proceed as if it
weren't stated. This now results in a diagnostic:
The return type above should be written as
some P<Array<Int>>
to matchthe return statement. The old broken behavior in this situation can also
be restored, by removing the erroneous constraint and using the more general
upper bound
some P
.[SE-0408][]:
A
for
-in
loop statement can now accept a pack expansion expression,enabling iteration over the elements of its respective value pack. This form
supports pattern matching, control transfer statements, and other features
available to a
Sequence
-drivenfor
-in
loop, except for thewhere
clause. Below is an example implementation of the equality operator for
tuples of arbitrary length using pack iteration:
The elements of the value pack corresponding to the pack expansion expression
are evaluated on demand, meaning the ith element is evaluated on
the ith iteration:
[SE-0352][]:
The Swift 6 language mode will open existential values with
"self-conforming" types (such as
any Error
or@objc
protocols)passed to generic functions. For example:
This behavior can be enabled prior to the Swift 6 language mode
using the upcoming language feature
ImplicitOpenExistentials
.[SE-0422][]:
Non-built-in expression macros can now be used as default arguments that
expand at each call site. For example, a custom
#CurrentFile
macro used asa default argument in 'Library.swift' won't be expanded to
"Library.swift"
:Instead, it will be expanded at where the function is called:
The expanded code can also use declarations from the caller side context:
[SE-0417][]:
Tasks now gain the ability to respect Task Executor preference.
This allows tasks executing default actors (which do not declare a custom executor),
and nonisolated asynchronous functions to fall back to a preferred executor, rather than always
executing on the default global pool.
The executor preference may be stated using the
withTaskExecutorPreference
function:Or when creating new unstructured or child-tasks (e.g. in a task group):
[SE-0413][]:
Functions can now specify the type of error that they throw as part of the
function signature. For example:
A call to
parseRecord(from:)
will either return aRecord
instance or throwan error of type
ParseError
. For example, ado..catch
block will inferthe
error
variable as being of typeParseError
:Typed throws generalizes over throwing and non-throwing functions. A function
that is specified as
throws
(without an explicitly-specified error type) isequivalent to one that specifies
throws(any Error)
, whereas a non-throwingis equivalent to one that specifies
throws(Never)
. Calls to functions thatare
throws(Never)
are non-throwing.Typed throws can also be used in generic functions to propagate error types
from parameters, in a manner that is more precise than
rethrows
. Forexample, the
Sequence.map
operation can propagate the thrown error type fromits closure parameter, indicating that it only throws errors of the same type
as that closure does:
When given a non-throwing closure as a parameter,
map
will not throw.[#70065][]:
With the implementation of [SE-0110][], a closure parameter syntax consisting
of only a parameter type — and no parameter name — was accidentally made legal
for certain unambiguous type syntaxes in Swift 4. For example:
Having been gated behind a
compiler warning since at least Swift 5.2, this syntax is now rejected.
[#71075][]:
_SwiftConcurrencyShims used to declare the
exit
function, even though itmight not be available. The declaration has been removed, and must be imported
from the appropriate C library module (e.g. Darwin or SwiftGlibc)
[SE-0270][]:
The Standard Library now provides APIs for performing collection operations
over noncontiguous elements. For example:
The standard library now provides a new
indices(where:)
function which createsa
RangeSet
- a new type representing a set of discontiguous indices.RangeSet
is generic over its index type and can be used to execute operations over
noncontiguous indices such as collecting, moving, or removing elements from a
collection. Additionally,
RangeSet
is generic over anyComparable
collectionindex and can be used to represent a selection of items in a list or a refinement
of a filter or search result.
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Renovate Bot.