forked from OSchip/llvm-project
Fixes block type matching bug. Radar 8302845.
llvm-svn: 110950
This commit is contained in:
parent
0910689353
commit
753783a062
|
@ -4336,7 +4336,7 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs,
|
|||
// when comparing an id<P> on rhs with a static type on lhs,
|
||||
// static class must implement all of id's protocols directly or
|
||||
// indirectly through its super class.
|
||||
if (lhsID->ClassImplementsProtocol(*I, false)) {
|
||||
if (lhsID->ClassImplementsProtocol(*I, true)) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -104,3 +104,20 @@ void test3() {
|
|||
f4(^(NSArray<P2>* a) { }); // expected-error {{incompatible block pointer types passing 'void (^)(NSArray<P2> *)' to parameter of type 'void (^)(id<P>)'}}
|
||||
}
|
||||
|
||||
// rdar : //8302845
|
||||
@protocol Foo @end
|
||||
|
||||
@interface Baz @end
|
||||
|
||||
@interface Baz(FooConformance) <Foo>
|
||||
@end
|
||||
|
||||
@implementation Baz @end
|
||||
|
||||
int test4 () {
|
||||
id <Foo> (^b)() = ^{ // Doesn't work
|
||||
return (Baz *)0;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ int main()
|
|||
MyOtherClass<MyProtocol> *obj_c_super_p_q = nil;
|
||||
MyClass<MyProtocol> *obj_c_cat_p_q = nil;
|
||||
|
||||
obj_c_cat_p = obj_id_p; // expected-warning {{assigning to 'MyClass *' from incompatible type 'id<MyProtocol>'}}
|
||||
obj_c_super_p = obj_id_p; // expected-warning {{assigning to 'MyOtherClass *' from incompatible type 'id<MyProtocol>'}}
|
||||
obj_c_cat_p = obj_id_p;
|
||||
obj_c_super_p = obj_id_p;
|
||||
obj_id_p = obj_c_cat_p; /* Ok */
|
||||
obj_id_p = obj_c_super_p; /* Ok */
|
||||
|
||||
|
|
Loading…
Reference in New Issue