Compiler errors out when setting a nullable dictionary with an extensible string enum to nil
Originator: | michaelhochs | ||
Number: | rdar://27966674 | Date Originated: | 23-Aug-2016 03:19 PM |
Status: | Open | Resolved: | |
Product: | Developer Tools | Product Version: | Xcode 8 beta 6, Swift 3 |
Classification: | Serious Bug | Reproducible: | Always |
Summary: With Swift 3 we can now use `NS_EXTENSIBLE_STRING_ENUM` to make `NSString`s become an enum in Swift. When doing so for a list of keys that can be set in a dictionary and then making that dictionary parameter `nullable` Swift no longer compiles if you pass `nil` to that argument. Steps to reproduce: 0. Open the attached Sample project and compile it or: in ObjC: 1. Create a typedef for NSString * that has NS_EXTENSIBLE_STRING_ENUM set 2. Create a couple of values for that type 3. Create a method that takes an argument nullable NSDictionary<YourExtensibleStringEnumType, id> * in Swift: 4. Call the method you created in step 3 and pass nil as the value for the parameter, so that no dictionary is set. Expected behavior: This compiles fine as the argument is nullable Actual behavior: This errors out with the message: Undefined symbols for architecture x86_64: "protocol witness table for __C. YourExtensibleStringEnumType : Swift.Hashable in __ObjC", referenced from: ... Notes: This is fixed as soon as you call the same method with a non-nil value somewhere in the same scope. In this case, calling it with nil as well works just fine. I filed this as well as SR-2460 in the Swift bug tracker
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Sample code: https://github.com/PSPDFKit-labs/radar.apple.com/tree/master/27966674%20-%20ExtensibleStringEnums