| 1 |
// RUN: %clang_cc1 -Wstrict-selector-match -fsyntax-only -verify %s |
| 2 |
|
| 3 |
@interface Foo |
| 4 |
-(int) method; // expected-note {{using}} |
| 5 |
@end |
| 6 |
|
| 7 |
@interface Bar |
| 8 |
-(float) method; // expected-note {{also found}} |
| 9 |
@end |
| 10 |
|
| 11 |
int main(void) { [(id)0 method]; } // expected-warning {{multiple methods named 'method' found}} |
| 12 |
|
| 13 |
@interface Object @end |
| 14 |
|
| 15 |
@interface Class1 |
| 16 |
- (void)setWindow:(Object *)wdw; // expected-note 2 {{using}} |
| 17 |
@end |
| 18 |
|
| 19 |
@interface Class2 |
| 20 |
- (void)setWindow:(Class1 *)window; // expected-note 2 {{also found}} |
| 21 |
@end |
| 22 |
|
| 23 |
id foo(void) { |
| 24 |
Object *obj = 0; |
| 25 |
id obj2 = obj; |
| 26 |
[obj setWindow:0]; // expected-warning {{Object' may not respond to 'setWindow:'}} \ |
| 27 |
// expected-warning {{multiple methods named 'setWindow:' found}} |
| 28 |
[obj2 setWindow:0]; // expected-warning {{multiple methods named 'setWindow:' found}} |
| 29 |
return obj; |
| 30 |
} |
| 31 |
|
| 32 |
@protocol MyObject |
| 33 |
- (id)initWithData:(Object *)data; // expected-note {{also found}} |
| 34 |
@end |
| 35 |
|
| 36 |
@protocol SomeOther |
| 37 |
- (id)initWithData:(int)data; // expected-note {{also found}} |
| 38 |
@end |
| 39 |
|
| 40 |
@protocol MyCoding |
| 41 |
- (id)initWithData:(id<MyObject, MyCoding>)data; // expected-note {{using}} |
| 42 |
@end |
| 43 |
|
| 44 |
@interface NTGridDataObject: Object <MyCoding> |
| 45 |
{ |
| 46 |
Object<MyCoding> *_data; |
| 47 |
} |
| 48 |
+ (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data; |
| 49 |
@end |
| 50 |
|
| 51 |
@implementation NTGridDataObject |
| 52 |
- (id)initWithData:(id<MyObject, MyCoding>)data { // expected-note {{also found}} |
| 53 |
return data; |
| 54 |
} |
| 55 |
+ (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data |
| 56 |
{ |
| 57 |
NTGridDataObject *result = [(id)0 initWithData:data]; // expected-warning {{multiple methods named 'initWithData:' found}} |
| 58 |
return result; |
| 59 |
} |
| 60 |
@end |
| 61 |
|
| 62 |
@interface Base |
| 63 |
- (unsigned)port; |
| 64 |
@end |
| 65 |
|
| 66 |
@interface Derived: Base |
| 67 |
- (Object *)port; |
| 68 |
+ (Protocol *)port; |
| 69 |
@end |
| 70 |
|
| 71 |
void foo1(void) { |
| 72 |
[(Class)0 port]; // OK - gcc issues warning but there is only one Class method so no ambiguity to warn |
| 73 |
} |
| 74 |
|
| 75 |
@interface NSObject |
| 76 |
- (id)class; |
| 77 |
- (id) alloc; |
| 78 |
@end |
| 79 |
|
| 80 |
@class NSString; |
| 81 |
|
| 82 |
@interface A : NSObject |
| 83 |
- (instancetype)initWithType:(NSString *)whatever; // expected-note {{also found}} |
| 84 |
@end |
| 85 |
|
| 86 |
@interface Test : NSObject |
| 87 |
@end |
| 88 |
|
| 89 |
@implementation Test |
| 90 |
+ (instancetype)foo |
| 91 |
{ |
| 92 |
return [[[self class] alloc] initWithType:3]; // expected-warning {{multiple methods named 'initWithType:'}} |
| 93 |
} |
| 94 |
|
| 95 |
- (instancetype)initWithType:(unsigned int)whatever // expected-note {{using}} |
| 96 |
{ |
| 97 |
return 0; |
| 98 |
} |
| 99 |
@end |