-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[SR-14878] Enum cases with associated values cannot be marked potentially unavailable with '@available' #57225
Comments
Not able to reproduce with Xcode 13 beta 2 or main. Is that the only code, or is there more to it? Are you seeing a compiler error (if so, what is the error)? Is the problem that the availability annotations are not being honored correctly? @swift-ci create |
Comment by Gereon Steffens (JIRA) The attached project shows the issue, it builds in Xcode 12.5.1 and fails to build in Xcode 13 beta 2. The error message is
on line 11 of ViewController.swift. A couple of other reports of this issue can be found at https://developer.apple.com/forums/thread/682351 |
Comment by Gereon Steffens (JIRA) I first came across this issue when trying to build a project targeting iOS 12, which includes the SwiftMessages library, and building that failed on https://github.com/SwiftKickMobile/SwiftMessages/blob/master/SwiftMessages/SwiftMessages.swift#L82 |
Huh, that's weird. I don't see the error when the availability annotation uses 13.0 but I do see the error when it is 14.0. The app's own deployment target is 13.0, which seems related. |
This is intentional. The ABI of enum cases with payloads that are potentially unavailable is not well-defined. That this worked in the past was by coincidence of your application not requiring the (potentially unavailable) type metadata for the payload. Please either increase your deployment target or mark Foo itself as available as the least-available case. |
Comment by Spandana Batchu (JIRA) Gereon (JIRA User) Im using SwiftMessages library and I see the same issue with Xcode 13 Beta. How did you resolve the issue? |
spandanabatchu (JIRA User) You (or SwiftMessages) must resolve this issue by either 1) Increasing your deployment target The compiler is warning you that the availability bounds there are not meaningful and may lead to poor behavior if relied upon for their intended purpose. |
Comment by Gereon Steffens (JIRA) spandanabatchu (JIRA User) there is a workaround described here: SwiftKickMobile/SwiftMessages#471 (comment) |
Attachment: Download
Environment
Xcode 13 beta 2 on macOS 11.4 (Intel)
Additional Detail from JIRA
md5: 7d073033bcd79fe82b5f2ab19dd0d073
Issue Description:
Code that uses `@available` for enum cases that have associated values no longer compiles:
enum Foo {
@available(iOS 13.0, *)
case bar(Int)
case baz
}
This code compiled fine in Xcode12, but doesn't in Xcode 13 (both beta 1 and 2)
The text was updated successfully, but these errors were encountered: