Type System is Unsafe Under Foundation Bridging

Originator:widmannrobert
Number:rdar://20867983 Date Originated:07-May-2015 08:58 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 6.4 (6E14)
Classification:Serious Bug Reproducible:Always
 
Summary:
When bridging with Foundation is enabled (as it seems to be all the time always, but that's another radar) there are certain cases where Swift's attempts to unify generic constraints will resolve to NSObject and result in unsafe code.

Steps to Reproduce:
1. Open a new playground
2. import Foundation
3. Copy and paste the code in the linked gist into the playground:

https://gist.github.com/CodaFi/27e750c8aad4e3589ff1

4. Comment and uncomment the Foundation import; line 40 will switch between passing and failing typechecking.

Expected Results:
The bridging mechanism does not resolve generic type constraints that may result in unsafe code.

Actual Results:
The bridging mechanism provides the typechecker ample opportunity to accidentally unify constraints that result in unsafe code.

Version:
Xcode 6.4 (6E14)

Notes:


Configuration:


Attachments:

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!