Keep the source location of the selector in ObjCMessageExpr.
[clang.git] / test / SemaObjC / method-conflict-1.m
blob3cf2c6b5a908b434d9b25ef16877951bdc6cc426
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // This test case tests the default behavior.
5 // rdar://7933061
7 @interface NSObject @end
9 @interface NSArray : NSObject @end
11 @interface MyClass : NSObject {
13 - (void)myMethod:(NSArray *)object;
14 - (void)myMethod1:(NSObject *)object; // broken-note {{previous definition is here}}
15 @end
17 @implementation MyClass
18 - (void)myMethod:(NSObject *)object {
20 - (void)myMethod1:(NSArray *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}}
22 @end
25 @protocol MyProtocol @end
27 @interface MyOtherClass : NSObject <MyProtocol> {
29 - (void)myMethod:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
30 - (void)myMethod1:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
31 @end
33 @implementation MyOtherClass
34 - (void)myMethod:(MyClass *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod:': 'id<MyProtocol>' vs 'MyClass *'}}
36 - (void)myMethod1:(MyClass<MyProtocol> *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id<MyProtocol>' vs 'MyClass<MyProtocol> *'}}
38 @end
42 @interface A @end
43 @interface B : A @end
45 @interface Test1 {}
46 - (void) test1:(A*) object; // broken-note {{previous definition is here}} 
47 - (void) test2:(B*) object;
48 @end
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
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
65 @interface Test3 {}
66 - (A*) test1;
67 - (B*) test2; // broken-note {{previous definition is here}} 
68 @end
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
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