1 // RUN: %clang_cc1 -fsyntax-only -verify %s
6 @protocol SomeProtocol1
9 @interface SomeObject <SomeProtocol>
13 Class <SomeProtocol> classA;
14 Class <SomeProtocol> classB;
15 Class <SomeProtocol, SomeProtocol1> classC;
16 Class <SomeProtocol1> classD;
25 return classA == classB || classA == classC ||
27 classA == classD; // expected-warning {{comparison of distinct pointer types ('Class<SomeProtocol>' and 'Class<SomeProtocol1>')}}
30 @protocol NSObject @end
32 @interface NSObject @end
33 @protocol ProtocolX <NSObject>
36 @protocol ProtocolY <NSObject>
39 @interface ClassA : NSObject
42 @interface ClassB : ClassA <ProtocolY, ProtocolX>
45 @interface OtherClass : NSObject
46 @property (nonatomic, copy) ClassB<ProtocolX> *aProperty;
47 - (ClassA<ProtocolY> *)aMethod;
48 - (ClassA<ProtocolY> *)anotherMethod;
51 @implementation OtherClass
52 - (ClassA<ProtocolY> *)aMethod {
53 // This does not work, even though ClassB subclasses from A and conforms to Y
54 // because the property type explicitly adds ProtocolX conformance
55 // even though ClassB already conforms to ProtocolX
56 return self.aProperty;
58 - (ClassA<ProtocolY> *)anotherMethod {
59 // This works, even though all it is doing is removing an explicit
60 // protocol conformance that ClassB already conforms to
61 return (ClassB *)self.aProperty;