Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FB14338964: Breaking - Incorrect Swift 6 Concurrency Errors in Swift 5 project #563

Open
macmade opened this issue Sep 25, 2024 · 3 comments

Comments

@macmade
Copy link

macmade commented Sep 25, 2024

  • Date: 2024-06-16
  • Resolution: Open
  • Area: Swift Compiler
  • OS: macOS
  • Type: Incorrect/Unexpected Behavior
  • Keywords: swift, compiler, concurrency, error, warning

Description

Concurrency errors related to the Sendable protocol are produced in a project, although it is configured for Swift 5.
This behavior is new in Xcode 16.0 beta 3 (16A5202i) and breaks the build.
Previous beta versions were not affected.

I've attached an Xcode project showing the issues.

Error 1 - Using WebKit:

import WebKit

This produces the following error: Add '@preconcurrency' to suppress 'Sendable'-related warnings from module 'WebKit'

Error 2 - Using @preconcurrency

@preconcurrency import WebKit

In a Swift 5 project, this produces the following error: '@preconcurrency' attribute on module 'WebKit' has no effect

Error 3 - Closures and Sendable

let test = NSTreeController()
[self.observer](http://self.observer/) = self.observe( \.description )
{
    _, _ in print( test )
}

Capture of 'test' with non-sendable type 'NSTreeController' in a @Sendable closure; this is an error in the Swift 6 language mode

These issues make building a Swift 5 project impossible with Xcode 16.0 beta 3.

Files

Test.zip

@macmade
Copy link
Author

macmade commented Sep 25, 2024

This project has warnings-as-errors turned on. Switch the build setting and the warnings are just that - only warnings. This is correct behavior.

@macmade
Copy link
Author

macmade commented Sep 25, 2024

The project indeed has warnings-as-errors enabled.
Disabling this is not a valid solution. Treating warnings as errors can be a requirement on some projects.

At least provide a way to turn these warnings in Swift 5 projects as a build setting.

@macmade
Copy link
Author

macmade commented Sep 25, 2024

Since there is a -warn-concurrency flag, please provide a -no-warn-concurrency or -disable-warn-concurrency so we can use them on specific files while keeping warning as errors on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant