Swift: Covariant array assignment crashes at runtime with EXC_BAD_ACCESS error
| Originator: | adrian.kashivskyy | ||
| Number: | rdar://17894354 | Date Originated: | 02-Aug-2014 11:52 AM |
| Status: | Dupe/18480439/Closed | Resolved: | Yes |
| Product: | Developer Tools | Product Version: | Xcode 6.0 Beta 4 (6A267n) |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
Covariant array assignment doesn't work as expected in Swift – it should either be prevented at compile-time or work properly at runtime.
In Xcode6-Beta4, things like
let array : [MyProtocol] = [MyClass()] as [MyClass] // MyClass conforms to MyProtocol
should work without any error, since MyClass is a subtype of MyProtocol.
Yet doing such operation ends up with a runtime EXC_BAD_ACCESS error.
Steps to Reproduce:
1. Install Xcode6-Beta4
2. Open the attached "covariant-array-assignment.playground" file
3. Execute the playground
Expected Results:
No runtime error, console displaying "1" (the array's count)
Actual Results:
Runtime EXC_BAD_ACCESS error, console displaying the backtrace (attached as "error-backtrace.log" for reference)
Version:
Xcode 6.0 Beta 4 (6A267n)
OS X 10.9.4 (13E28)
MacPro5,1
Notes:
Related Apple Developer Forums thread: https://devforums.apple.com/message/1015772
Configuration:
Issue is always reproducible, on any installation of Xcode6-Beta4 (6A267n)
Attachments:
'error-backtrace.log' and 'covariant-array-assignment.playground.zip' were successfully uploaded.
--- 28-Aug-2014 07:54 PM
I noticed that the uploaded playground file is damaged. Here is a link to the valid archive.
http://cl.ly/3j0a2b2t2D3K/download/rdar-17894354.zip
--- 22-Jan-2015 05:43 AM / ADR
Engineering has determined that your bug report is a duplicate of another issue and will be closed.
18480439
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!
Attachments
http://cl.ly/3j0a2b2t2D3K/download/rdar-17894354.zip