mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
CF <-> NS bridging is a subtype. Fixes rdar://problem/18297881
Swift SVN r21922
This commit is contained in:
@@ -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());
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user