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

[SR-8071] CaseIterable declared in Swift 4.2 compatibility modes #50604

Closed
swift-ci opened this issue Jun 22, 2018 · 2 comments
Closed

[SR-8071] CaseIterable declared in Swift 4.2 compatibility modes #50604

swift-ci opened this issue Jun 22, 2018 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8071
Radar None
Original Reporter tannernelson (JIRA User)
Type Bug
Status Resolved
Resolution Won't Do
Environment

Apple Swift version 4.2 (swiftlang-1000.0.16.9 clang-1000.10.25.3)
Target: x86_64-apple-darwin17.5.0

macOS 10.13.4

Xcode 10 beta 2 (tools version, Xcode 10)

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: d74cac47dc960580b2ed4091002580da

Issue Description:

`CaseIterable` was introduced in Swift 4.2, yet when compiling projects with the Swift 4.2 compiler in Swift 4.0 compatibility mode, the protocol is available. This is creating problems with a shim `CaseIterable` protocol I would like to declare only in < Swift 4.2.

#if swift(>=4.2)
#else
public protocol CaseIterable {
    static var allCases: [Self] { get }
}
#endif

When running Swift 4.1 compiler, `CaseIterable` is usable. When running Swift 4.2 compiler in 4.0 compat mode, `CaseIterable` becomes ambiguous.

Using the placeholder #compiler directive, I can get this to work.

#if swift(>=4.1.50)
#else
public protocol CaseIterable {
    static var allCases: [Self] { get }
}
#endif

This solution works fine for me, but I wanted to notify you all in case this is unexpected behavior.

Thanks and keep up the great work on Swift 4.2!

@belkadan
Copy link
Contributor

I think this is deliberate, so that people can adopt CaseIterable without having to migrate their whole project forwards. @airspeedswift?

@airspeedswift
Copy link
Member

Yes, we always want to make the new stuff available even to people running in compatibility mode where possible. That way they can use the new features even if they're held back from doing the full upgrade by some other issue they need to resolve.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants