blob: 3cf2c6b5a908b434d9b25ef16877951bdc6cc426 [file] [log] [blame]
Fariborz Jahanianbdaae392010-10-05 21:02:11 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
John McCall10302c02010-10-28 02:34:38 +00002
3// This test case tests the default behavior.
4
Fariborz Jahanianbdaae392010-10-05 21:02:11 +00005// rdar://7933061
6
7@interface NSObject @end
8
9@interface NSArray : NSObject @end
10
11@interface MyClass : NSObject {
12}
John McCall10302c02010-10-28 02:34:38 +000013- (void)myMethod:(NSArray *)object;
14- (void)myMethod1:(NSObject *)object; // broken-note {{previous definition is here}}
Fariborz Jahanianbdaae392010-10-05 21:02:11 +000015@end
16
17@implementation MyClass
John McCall10302c02010-10-28 02:34:38 +000018- (void)myMethod:(NSObject *)object {
Fariborz Jahanianbdaae392010-10-05 21:02:11 +000019}
John McCall10302c02010-10-28 02:34:38 +000020- (void)myMethod1:(NSArray *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}}
Fariborz Jahanianbdaae392010-10-05 21:02:11 +000021}
22@end
23
24
25@protocol MyProtocol @end
26
27@interface MyOtherClass : NSObject <MyProtocol> {
28}
John McCall10302c02010-10-28 02:34:38 +000029- (void)myMethod:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
30- (void)myMethod1:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
Fariborz Jahanianbdaae392010-10-05 21:02:11 +000031@end
32
33@implementation MyOtherClass
John McCall10302c02010-10-28 02:34:38 +000034- (void)myMethod:(MyClass *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod:': 'id<MyProtocol>' vs 'MyClass *'}}
Fariborz Jahanianbdaae392010-10-05 21:02:11 +000035}
John McCall10302c02010-10-28 02:34:38 +000036- (void)myMethod1:(MyClass<MyProtocol> *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id<MyProtocol>' vs 'MyClass<MyProtocol> *'}}
Fariborz Jahanianbdaae392010-10-05 21:02:11 +000037}
38@end
John McCall10302c02010-10-28 02:34:38 +000039
40
41
42@interface A @end
43@interface B : A @end
44
45@interface Test1 {}
46- (void) test1:(A*) object; // broken-note {{previous definition is here}}
47- (void) test2:(B*) object;
48@end
49
50@implementation Test1
51- (void) test1:(B*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}}
52- (void) test2:(A*) object {}
53@end
54
55// rdar://problem/8597621 wants id -> A* to be an exception
56@interface Test2 {}
57- (void) test1:(id) object; // broken-note {{previous definition is here}}
58- (void) test2:(A*) object;
59@end
60@implementation Test2
61- (void) test1:(A*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}}
62- (void) test2:(id) object {}
63@end
64
65@interface Test3 {}
66- (A*) test1;
67- (B*) test2; // broken-note {{previous definition is here}}
68@end
69
70@implementation Test3
71- (B*) test1 { return 0; }
72- (A*) test2 { return 0; } // broken-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}}
73@end
74
75// The particular case of overriding with an id return is white-listed.
76@interface Test4 {}
77- (id) test1;
78- (A*) test2;
79@end
80@implementation Test4
81- (A*) test1 { return 0; } // id -> A* is rdar://problem/8596987
82- (id) test2 { return 0; }
83@end