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
11int main() { [(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 {{using}}
17@end
18
19@interface Class2
20- (void)setWindow:(Class1 *)window;	// expected-note {{also found}}
21@end
22
23id foo(void) {
24  Object *obj = 0;
25  id obj2 = obj;
26  [obj setWindow:0]; 	// expected-warning {{Object' may not respond to 'setWindow:'}}
27  [obj2 setWindow:0]; // expected-warning {{multiple methods named 'setWindow:' found}}
28  return obj;
29}
30
31@protocol MyObject
32- (id)initWithData:(Object *)data;	// expected-note {{using}} \
33					// expected-note {{passing argument to parameter 'data' here}}
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 {{also found}}
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 {
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    expected-warning {{sending 'id<MyObject,MyCoding>' to parameter of incompatible type 'Object *'}}
59    return result;
60}
61@end
62
63@interface Base
64- (unsigned)port;
65@end
66
67@interface Derived: Base
68- (Object *)port;
69+ (Protocol *)port;
70@end
71
72void foo1(void) {
73  [(Class)0 port]; // OK - gcc issues warning but there is only one Class method so no ambiguity to warn
74}
75
76