[swift-evolution] Discussion: Enforce usage of @available on enum cases

Jordan Rose jordan_rose at apple.com
Wed May 25 22:17:19 CDT 2016


The “*” in @available means “all other platforms”. If you want to mark something unavailable on a particular platform, you’ll have to use the long form of the @available attribute. There’s currently no way to mark something “only available on these platforms”.

Jordan

> On May 25, 2016, at 18:48, Stuart Breckenridge via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Presently, you can mark enum cases as @available but it has no impact. Take the following example:
> 
> enum Things:String {
> 	@available (iOS 9.3, *) case MobileThing = "com.example.mobilething"
> 	@available (OSX 10.11, *) case DesktopThing = "com.example.desktopthing"
> }
> 
> Despite the above compiling, the following code will run iOS with no warnings:
> 
> func takesA(thing:Things) {
> 	print(thing)
> }
> 
> takesA(.DesktopThing)
> 
> 
> Are there enough compelling use-cases for @available on enum cases to be considered? At the very least, if @available doesn't do anything on cases, it shouldn't be permitted.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160525/3ecc3ecf/attachment.html>


More information about the swift-evolution mailing list