Swift crash/fatal error when casting optional

Originator:m.purland
Number:rdar://17643982 Date Originated:7/11/2014
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 6 beta 3
Classification: Reproducible:Always
 
Summary:
Swift runtime crashes when casting optional type to non-optional type.

Error:
fatal error: can't reinterpretCast values of different sizes

Code:

import UIKit
import XCTest

class User {
    var dict: [String:String]?
}

class SwiftReinterpretCastCrashTests: XCTestCase {
    
    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    func testCrash() {
        var user = User()
        user.dict = ["email":"john.doe@somewhere.com"]
        // Next line crashes with: fatal error: can't reinterpretCast values of different sizes
        let a = user.dict as [String: String]
    }
    
}

Steps to Reproduce:
Build and run tests.

Expected Results:
Swift runtime should downcast optional  [String: String]? to [String: String]

Actual Results:
Fatal error received causing crash:

fatal error: can't reinterpretCast values of different sizes

Version:
Yosemite Developer Preview 3, Xcode 6 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!