Skip to content

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Mar 7, 2025

This PR contains the following updates:

Package Update Change
swiftlang/swift minor 5.8 -> 5.10.1

Release Notes

swiftlang/swift (swiftlang/swift)

v5.10.1: Swift 5.10.1 Release

Compare Source

v5.10

Compare Source

2024-03-05 (Xcode 15.3)
  • Swift 5.10 closes all known static data-race safety holes in complete strict
    concurrency checking.

    When writing code against -strict-concurrency=complete, Swift 5.10 will
    diagnose all potential for data races at compile time unless an explicit
    unsafe opt out, such as nonisolated(unsafe) or @unchecked Sendable, is
    used.

    For example, in Swift 5.9, the following code crashes at runtime due to a
    @MainActor-isolated initializer being evaluated outside the actor, but it
    was not diagnosed under -strict-concurrency=complete:

    @​MainActor
    class MyModel {
      init() {
        MainActor.assertIsolated()
      }
    
      static let shared = MyModel()
    }
    
    func useShared() async {
      let model = MyModel.shared
    }
    
    await useShared()

    The above code admits data races because a @MainActor-isolated static
    variable, which evaluates a @MainActor-isolated initial value upon first
    access, is accessed synchronously from a nonisolated context. In Swift
    5.10, compiling the code with -strict-concurrency=complete produces a
    warning that the access must be done asynchronously:

    warning: expression is 'async' but is not marked with 'await'
      let model = MyModel.shared
                  ^~~~~~~~~~~~~~
                  await
    

    Swift 5.10 fixed numerous other bugs in Sendable and actor isolation
    checking to strengthen the guarantees of complete concurrency checking.

    Note that the complete concurrency model in Swift 5.10 is conservative.
    Several Swift Evolution proposals are in active development to improve the
    usability of strict concurrency checking ahead of Swift 6.

  • [SE-0412][]:

    Global and static variables are prone to data races because they provide memory that can be accessed from any program context. Strict concurrency checking in Swift 5.10 prevents data races on global and static variables by requiring them to be either:

    1. isolated to a global actor, or
    2. immutable and of Sendable type.

    For example:

    var mutableGlobal = 1
    // warning: var 'mutableGlobal' is not concurrency-safe because it is non-isolated global shared mutable state
    // (unless it is top-level code which implicitly isolates to @​MainActor)
    
    @​MainActor func mutateGlobalFromMain() {
      mutableGlobal += 1
    }
    
    nonisolated func mutateGlobalFromNonisolated() async {
      mutableGlobal += 10
    }
    
    struct S {
      static let immutableSendable = 10
      // okay; 'immutableSendable' is safe to access concurrently because it's immutable and 'Int' is 'Sendable'
    }

    A new nonisolated(unsafe) modifier can be used to annotate a global or static variable to suppress data isolation violations when manual synchronization is provided:

    // This global is only set in one part of the program
    nonisolated(unsafe) var global: String!

    nonisolated(unsafe) can be used on any form of storage, including stored properties and local variables, as a more granular opt out for Sendable checking, eliminating the need for @unchecked Sendable wrapper types in many use cases:

    import Dispatch
    
    // 'MutableData' is not 'Sendable'
    class MutableData { ... } 
    
    final class MyModel: Sendable {
      private let queue = DispatchQueue(...)
      // 'protectedState' is manually isolated by 'queue'
      nonisolated(unsafe) private var protectedState: MutableData
    }

    Note that without correct implementation of a synchronization mechanism to achieve data isolation, dynamic run-time analysis from exclusivity enforcement or tools such as the Thread Sanitizer could still identify failures.

  • [SE-0411][]:

    Swift 5.10 closes a data-race safety hole that previously permitted isolated
    default stored property values to be synchronously evaluated from outside the
    actor. For example, the following code compiles warning-free under
    -strict-concurrency=complete in Swift 5.9, but it will crash at runtime at
    the call to MainActor.assertIsolated():

    @​MainActor func requiresMainActor() -> Int {
      MainActor.assertIsolated()
      return 0
    }
    
    @​MainActor struct S {
      var x = requiresMainActor()
      var y: Int
    }
    
    nonisolated func call() async {
      let s = await S(y: 10)
    }
    
    await call()

    This happens because requiresMainActor() is used as a default argument to
    the member-wise initializer of S, but default arguments are always
    evaluated in the caller. In this case, the caller runs on the generic
    executor, so the default argument evaluation crashes.

    Under -strict-concurrency=complete in Swift 5.10, default argument values
    can safely share the same isolation as the enclosing function or stored
    property. The above code is still valid, but the isolated default argument is
    guaranteed to be evaluated in the callee's isolation domain.

v5.9.2

Compare Source

2023-12-11 (Xcode 15.1)
  • [SE-0407][]:

    Member macros can specify a list of protocols via the conformances argument to the macro role. The macro implementation will be provided with those protocols that are listed but have not already been implemented by the type to which the member macro is attached, in the same manner as extension macros.

    @​attached(member, conformances: Decodable, Encodable, names: named(init(from:), encode(to:)))
    @​attached(extension, conformances: Decodable, Encodable, names: named(init(from:), encode(to:)))
    macro Codable() = #externalMacro(module: "MyMacros", type: "CodableMacro")

v5.9.1: Swift 5.9.1 Release

Compare Source

v5.9

Compare Source

2023-12-11 (Xcode 15.1)
  • [SE-0407][]:

    Member macros can specify a list of protocols via the conformances argument to the macro role. The macro implementation will be provided with those protocols that are listed but have not already been implemented by the type to which the member macro is attached, in the same manner as extension macros.

    @​attached(member, conformances: Decodable, Encodable, names: named(init(from:), encode(to:)))
    @​attached(extension, conformances: Decodable, Encodable, names: named(init(from:), encode(to:)))
    macro Codable() = #externalMacro(module: "MyMacros", type: "CodableMacro")

v5.8.1: Swift 5.8.1 Release

Compare Source


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 is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@codecov
Copy link

codecov bot commented Mar 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.21%. Comparing base (8a1e19d) to head (30fee5f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #99   +/-   ##
=======================================
  Coverage   97.21%   97.21%           
=======================================
  Files          24       24           
  Lines        1435     1435           
=======================================
  Hits         1395     1395           
  Misses         40       40           
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@renovate renovate bot force-pushed the renovate/swiftlang-swift-5.x branch 5 times, most recently from 3bf1b92 to d9def3a Compare March 7, 2025 22:29
@renovate renovate bot force-pushed the renovate/swiftlang-swift-5.x branch from d9def3a to d2d1621 Compare March 7, 2025 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants