Xcode-6.3 (6D570): Compiler not detecting contravariant return type, runtime memory corruption
| Originator: | segiddins | ||
| Number: | rdar://20500882 | Date Originated: | 10-Apr-2015 11:19 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-6.3 (6D570) |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary:
The compiler should error when a subclass overrides a function with a contravariant return type.
There shouldn't be ann EXC_BAD_ACCESS at runtime.
Steps to Reproduce:
Compile + run the following swift code:
class A {
class func f() -> String? {
return nil
}
}
class B : A {
override class func f() -> String {
return "this should be printed!"
}
}
println(B.f())
B()
Expected Results:
The compiler should error when a subclass overrides a function with a contravariant return type.
There shouldn't be ann EXC_BAD_ACCESS at runtime.
Actual Results:
The code compiles and there’s an EXC_BAD_ACCESS at runtime.
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!