83 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s2// expected-no-diagnostics3 4// This test case tests the default behavior.5 6@interface NSObject @end7 8@interface NSArray : NSObject @end9 10@interface MyClass : NSObject {11}12- (void)myMethod:(NSArray *)object;13- (void)myMethod1:(NSObject *)object; // broken-note {{previous definition is here}}14@end15 16@implementation MyClass17- (void)myMethod:(NSObject *)object {18}19- (void)myMethod1:(NSArray *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}}20}21@end22 23 24@protocol MyProtocol @end25 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@end31 32@implementation MyOtherClass33- (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@end38 39 40 41@interface A @end42@interface B : A @end43 44@interface Test1 {}45- (void) test1:(A*) object; // broken-note {{previous definition is here}} 46- (void) test2:(B*) object;47@end48 49@implementation Test150- (void) test1:(B*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}}51- (void) test2:(A*) object {}52@end53 54// wants id -> A* to be an exception55@interface Test2 {}56- (void) test1:(id) object; // broken-note {{previous definition is here}} 57- (void) test2:(A*) object;58@end59@implementation Test260- (void) test1:(A*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}}61- (void) test2:(id) object {}62@end63 64@interface Test3 {}65- (A*) test1;66- (B*) test2; // broken-note {{previous definition is here}} 67@end68 69@implementation Test370- (B*) test1 { return 0; }71- (A*) test2 { return 0; } // broken-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}}72@end73 74// The particular case of overriding with an id return is permitted.75@interface Test4 {}76- (id) test1;77- (A*) test2;78@end79@implementation Test480- (A*) test1 { return 0; }81- (id) test2 { return 0; }82@end83