| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
| 2 |
// expected-no-diagnostics |
| 3 |
|
| 4 |
// This test case tests the default behavior. |
| 5 |
|
| 6 |
@interface NSObject @end |
| 7 |
|
| 8 |
@interface NSArray : NSObject @end |
| 9 |
|
| 10 |
@interface MyClass : NSObject { |
| 11 |
} |
| 12 |
- (void)myMethod:(NSArray *)object; |
| 13 |
- (void)myMethod1:(NSObject *)object; // broken-note {{previous definition is here}} |
| 14 |
@end |
| 15 |
|
| 16 |
@implementation MyClass |
| 17 |
- (void)myMethod:(NSObject *)object { |
| 18 |
} |
| 19 |
- (void)myMethod1:(NSArray *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}} |
| 20 |
} |
| 21 |
@end |
| 22 |
|
| 23 |
|
| 24 |
@protocol MyProtocol @end |
| 25 |
|
| 26 |
@interface MyOtherClass : NSObject <MyProtocol> { |
| 27 |
} |
| 28 |
- (void)myMethod:(id <MyProtocol>)object; // broken-note {{previous definition is here}} |
| 29 |
- (void)myMethod1:(id <MyProtocol>)object; // broken-note {{previous definition is here}} |
| 30 |
@end |
| 31 |
|
| 32 |
@implementation MyOtherClass |
| 33 |
- (void)myMethod:(MyClass *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod:': 'id<MyProtocol>' vs 'MyClass *'}} |
| 34 |
} |
| 35 |
- (void)myMethod1:(MyClass<MyProtocol> *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id<MyProtocol>' vs 'MyClass<MyProtocol> *'}} |
| 36 |
} |
| 37 |
@end |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
@interface A @end |
| 42 |
@interface B : A @end |
| 43 |
|
| 44 |
@interface Test1 {} |
| 45 |
- (void) test1:(A*) object; // broken-note {{previous definition is here}} |
| 46 |
- (void) test2:(B*) object; |
| 47 |
@end |
| 48 |
|
| 49 |
@implementation Test1 |
| 50 |
- (void) test1:(B*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}} |
| 51 |
- (void) test2:(A*) object {} |
| 52 |
@end |
| 53 |
|
| 54 |
// wants id -> A* to be an exception |
| 55 |
@interface Test2 {} |
| 56 |
- (void) test1:(id) object; // broken-note {{previous definition is here}} |
| 57 |
- (void) test2:(A*) object; |
| 58 |
@end |
| 59 |
@implementation Test2 |
| 60 |
- (void) test1:(A*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}} |
| 61 |
- (void) test2:(id) object {} |
| 62 |
@end |
| 63 |
|
| 64 |
@interface Test3 {} |
| 65 |
- (A*) test1; |
| 66 |
- (B*) test2; // broken-note {{previous definition is here}} |
| 67 |
@end |
| 68 |
|
| 69 |
@implementation Test3 |
| 70 |
- (B*) test1 { return 0; } |
| 71 |
- (A*) test2 { return 0; } // broken-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}} |
| 72 |
@end |
| 73 |
|
| 74 |
// The particular case of overriding with an id return is permitted. |
| 75 |
@interface Test4 {} |
| 76 |
- (id) test1; |
| 77 |
- (A*) test2; |
| 78 |
@end |
| 79 |
@implementation Test4 |
| 80 |
- (A*) test1 { return 0; } |
| 81 |
- (id) test2 { return 0; } |
| 82 |
@end |