Re: [swift-users] Handle deprecated enum cases from a library

2017-11-06 Thread Charles Srstka via swift-users
> On Nov 6, 2017, at 5:47 AM, Dennis Weissmann > wrote: > > Hey Charles, > > Thanks for going through this with me :) > > I'm not sure whether or not this is a compiler bug (that's partially why I > posted it here), although I have the feeling that *something* is

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-06 Thread Dennis Weissmann via swift-users
Hey Charles, Thanks for going through this with me :) I'm not sure whether or not this is a compiler bug (that's partially why I posted it here), although I have the feeling that *something* is definitely wrong. Funnily enough, the following code shows 3 compiler warnings which are

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-05 Thread Charles Srstka via swift-users
> On Nov 5, 2017, at 10:39 AM, Dennis Weissmann > wrote: > >> You can delete the default case here, and your switch will still be >> exhaustive > That's exactly my problem! It is *not*. > > When I delete the default clause, the compiler warns that the switch is not

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-05 Thread Dennis Weissmann via swift-users
> You can delete the default case here, and your switch will still be exhaustive That's exactly my problem! It is *not*. When I delete the default clause, the compiler warns that the switch is not exhaustive and fixits suggest to add the "missing" deprecated cases. - Dennis > On Nov 5, 2017,

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-05 Thread Charles Srstka via swift-users
> On Nov 5, 2017, at 9:27 AM, Dennis Weissmann > wrote: > > Hi Charles, > > I do believe you :) > > The problem is that this doesn't work without a compiler warning if you > switch over every case except for the deprecated ones because then the > compiler warns

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-05 Thread Dennis Weissmann via swift-users
Hi Charles, I do believe you :) The problem is that this doesn't work without a compiler warning if you switch over every case except for the deprecated ones because then the compiler warns that "default will never be executed". As per my first mail feel free to try this out in a playground:

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-05 Thread Charles Srstka via swift-users
> On Nov 5, 2017, at 3:14 AM, Dennis Weissmann > wrote: > > Hi Charles, > > You are right (the `default` case would not catch the deprecated values but > only new ones introduced in future releases), but the compiler doesn’t seem > to know that :( > > But now that

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-05 Thread somu subscribe via swift-users
Also noticed that when Xcode prompts to fill the missing case statements, it fills it with the deprecated TouchID case statements (in an iOS 11 project). > On 5 Nov 2017, at 5:14 PM, Dennis Weissmann via swift-users > wrote: > > Hi Charles, > > You are right (the

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-05 Thread Dennis Weissmann via swift-users
Hi Charles, You are right (the `default` case would not catch the deprecated values but only new ones introduced in future releases), but the compiler doesn’t seem to know that :( But now that you say it, one approach could be to pattern match the raw values (and, well, have a default clause,

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-04 Thread Charles Srstka via swift-users
> On Nov 4, 2017, at 9:38 AM, Dennis Weissmann via swift-users > wrote: > > Hi swift-users, > > In a project (iOS 11 only) we use Touch ID for authentication and handle > errors like so: > > private func handleLocalAuthenticationError(_ error: LAError) { > switch

[swift-users] Handle deprecated enum cases from a library

2017-11-04 Thread Dennis Weissmann via swift-users
Hi swift-users, In a project (iOS 11 only) we use Touch ID for authentication and handle errors like so: private func handleLocalAuthenticationError(_ error: LAError) { switch error.code { case .userCancel, .appCancel, .systemCancel: // Handle cancelation case