1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2 // expected-no-diagnostics
4 // This test case tests the default behavior.
8 @interface NSObject @end
10 @interface NSArray : NSObject @end
12 @interface MyClass : NSObject {
14 - (void)myMethod:(NSArray *)object;
15 - (void)myMethod1:(NSObject *)object; // broken-note {{previous definition is here}}
18 @implementation MyClass
19 - (void)myMethod:(NSObject *)object {
21 - (void)myMethod1:(NSArray *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}}
26 @protocol MyProtocol @end
28 @interface MyOtherClass : NSObject <MyProtocol> {
30 - (void)myMethod:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
31 - (void)myMethod1:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
34 @implementation MyOtherClass
35 - (void)myMethod:(MyClass *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod:': 'id<MyProtocol>' vs 'MyClass *'}}
37 - (void)myMethod1:(MyClass<MyProtocol> *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id<MyProtocol>' vs 'MyClass<MyProtocol> *'}}
47 - (void) test1:(A*) object; // broken-note {{previous definition is here}}
48 - (void) test2:(B*) object;
52 - (void) test1:(B*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}}
53 - (void) test2:(A*) object {}
56 // rdar://problem/8597621 wants id -> A* to be an exception
58 - (void) test1:(id) object; // broken-note {{previous definition is here}}
59 - (void) test2:(A*) object;
62 - (void) test1:(A*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}}
63 - (void) test2:(id) object {}
68 - (B*) test2; // broken-note {{previous definition is here}}
72 - (B*) test1 { return 0; }
73 - (A*) test2 { return 0; } // broken-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}}
76 // The particular case of overriding with an id return is white-listed.
82 - (A*) test1 { return 0; } // id -> A* is rdar://problem/8596987
83 - (id) test2 { return 0; }