Passing [NSObject] to a function expecting [Any] causes a run-time exception rather than compile time error
Originator: | Nick.Ager | ||
Number: | rdar://25799364 | Date Originated: | 2016-04-19 |
Status: | Open | Resolved: | |
Product: | Developer Tool | Product Version: | Xcode 7.3 (7D175) |
Classification: | Important | Reproducible: | Always |
Summary: Enter the following code into a playground and observe the runtime exception: --- func process(anArray : [Any]) { } let a = [1,2,[3],[4,[5,6]],[[7]], 8] process(a) --- the type inferred for 'a' is [NSObject] which results in: "fatal error: array cannot be bridged from Objective-C" Steps to Reproduce: 1. Xcode 7.3 2. Open a playground 3. Enter the code in the description 4. Reveal the "debug area" 5. Observe the runtime exception. Expected Results: The compiler should generate a compile type error for incompatible types i.e. '[NSObject]' cannot be passed to a function expecting '[Any]' Actual Results: Runtime exception - "fatal error: array cannot be bridged from Objective-C" Version: Xcode 7.3 (7D175), OS X 10.11.4 (15E65)
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!