Swift: array cast causes crash
| Originator: | garth | ||
| Number: | rdar://19423783 | Date Originated: | 08-Jan-2015 11:35 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6.2 beta 3 |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
This array cast causes a bad instruction error at runtime:
protocol ItemProtocol {
var duration: Float {get}
}
class TestItem: ItemProtocol {
let duration: Float = 42
}
let item = TestItem()
let testArray = [item] // Type is [TestItem]
let convertedArray = testArray as [ItemProtocol] // Error: bad instruction
It's not shown here, but in the actual use context from which I created this minimal example, the console also shows "fatal error: array element cannot be bridged to Objective-C". But there's no Objective-C in sight.
This might be related to the issue reported at https://devforums.apple.com/message/1069470#1069470, but in this case, everything is 100% Swift. There should be no bridging.
This is in Xcode 6.2 beta 3.
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!