Swift: instantiating subclass from MetaType does not work correctly
Originator: | thephatmann | ||
Number: | rdar://19096832 | Date Originated: | 30-Nov-2014 04:05 AM |
Status: | Duplicate of 19072746 | Resolved: | 18-Dec-2014 |
Product: | Developer Tools | Product Version: | Xcode 6.1.1 |
Classification: | Serious Bug | Reproducible: | Always |
If B is a subclass of A, then I can assign B.self to a variable of type A.Type. However, instantiating an object using that variable creates an instance of A, not B. Steps to Reproduce: class A { required init() {} func printMe() { println("A") } } class B : A { override func printMe() { println("B") } } var t : A.Type t = B.self let b = t() b.printMe() Expected Results: "B" Actual Results: "A"
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!