[sil-cast-optimizer] Fix casting between Swift and CF types

If a Swift type T needs to be casted to a CF type, then we first cast T to its bridged NS type and then ref_cast the result to a corresponding CF type.
For example, if we need to cast String to CFString, we first cast String to NSString and then ref_cast the NSString to CFString.

Fixes rdar://problem/29745498
This commit is contained in:
Roman Levenstein
2017-01-04 12:35:51 -08:00
parent b1c793e086
commit 830e1c36d4
4 changed files with 146 additions and 6 deletions

View File

@@ -262,7 +262,7 @@ classifyClassHierarchyCast(CanType source, CanType target) {
return DynamicCastFeasibility::WillFail;
}
static CanType getNSBridgedClassOfCFClass(Module *M, CanType type) {
CanType swift::getNSBridgedClassOfCFClass(Module *M, CanType type) {
if (auto classDecl = type->getClassOrBoundGenericClass()) {
if (classDecl->getForeignClassKind() == ClassDecl::ForeignKind::CFType) {
if (auto bridgedAttr =