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

Stuart Breckenridge stuart.breckenridge at icloud.com
Wed May 25 20:48:03 CDT 2016


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160526/9de7637e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3138 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160526/9de7637e/attachment.p7s>


More information about the swift-evolution mailing list