CF <-> NS bridging is a subtype. Fixes rdar://problem/18297881

Swift SVN r21922
This commit is contained in:
Doug Gregor
2014-09-12 20:57:53 +00:00
parent e002261865
commit 713ba3edd8
2 changed files with 10 additions and 1 deletions

View File

@@ -1443,7 +1443,8 @@ ConstraintSystem::matchTypes(Type type1, Type type2, TypeMatchKind kind,
}
// Check for CF <-> ObjectiveC bridging.
if (desugar1->getKind() == TypeKind::Class) {
if (desugar1->getKind() == TypeKind::Class &&
kind >= TypeMatchKind::Subtype) {
auto class1 = cast<ClassDecl>(nominal1->getDecl());
auto class2 = cast<ClassDecl>(nominal2->getDecl());

View File

@@ -67,3 +67,11 @@ func testUncheckableCasts(anyObject: AnyObject, nsObject: NSObject,
if let cfTreeType = anyObjectType as? CFTree.Type { } // expected-error{{conditional downcast to CoreFoundation type 'CFTree.Type' will always succeed}}
if let cfTreeType = nsObjectType as? CFTree.Type { } // expected-error{{'CFTree' is not a subtype of 'NSObject'}}
}
func testCFConvWithIUO(x: CFString!, y: NSString!) {
func acceptCFString(a: CFString!) { }
func acceptNSString(b: NSString!) { }
acceptNSString(x)
acceptCFString(y)
}