1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2 // expected-no-diagnostics
4 // This test case tests the default behavior.
6 @interface NSObject @end
8 @interface NSArray : NSObject @end
10 @interface MyClass : NSObject {
12 - (void)myMethod:(NSArray *)object;
13 - (void)myMethod1:(NSObject *)object; // broken-note {{previous definition is here}}
16 @implementation MyClass
17 - (void)myMethod:(NSObject *)object {
19 - (void)myMethod1:(NSArray *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}}
24 @protocol MyProtocol @end
26 @interface MyOtherClass : NSObject <MyProtocol> {
28 - (void)myMethod:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
29 - (void)myMethod1:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
32 @implementation MyOtherClass
33 - (void)myMethod:(MyClass *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod:': 'id<MyProtocol>' vs 'MyClass *'}}
35 - (void)myMethod1:(MyClass<MyProtocol> *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id<MyProtocol>' vs 'MyClass<MyProtocol> *'}}
45 - (void) test1:(A*) object; // broken-note {{previous definition is here}}
46 - (void) test2:(B*) object;
50 - (void) test1:(B*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}}
51 - (void) test2:(A*) object {}
54 // wants id -> A* to be an exception
56 - (void) test1:(id) object; // broken-note {{previous definition is here}}
57 - (void) test2:(A*) object;
60 - (void) test1:(A*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}}
61 - (void) test2:(id) object {}
66 - (B*) test2; // broken-note {{previous definition is here}}
70 - (B*) test1 { return 0; }
71 - (A*) test2 { return 0; } // broken-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}}
74 // The particular case of overriding with an id return is permitted.
80 - (A*) test1 { return 0; }
81 - (id) test2 { return 0; }