1 /* Check if finding multiple signatures for a method is handled gracefully when method lookup succeeds (see also method-7.m). */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com> */
3 /* { dg-options "-Wstrict-selector-match" } */
4 /* { dg-do compile } */
6 #include "../objc-obj-c++-shared/TestsuiteObject.h"
9 - (id)initWithData:(TestsuiteObject *)data; /* { dg-line MyObject_initWithData } */
13 - (id)initWithData:(int)data; /* { dg-line SomeOther_initWithData } */
17 - (id)initWithData:(id<MyObject, MyCoding>)data; /* { dg-line MyCoding_initWithData } */
20 @interface NTGridDataObject: TestsuiteObject <MyCoding>
22 TestsuiteObject<MyCoding> *_data;
24 + (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data;
27 @implementation NTGridDataObject
28 - (id)initWithData:(id<MyObject, MyCoding>)data {
31 + (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data
33 NTGridDataObject *result = [[NTGridDataObject alloc] initWithData:data]; /* { dg-line result_init } */
34 /* { dg-warning "multiple methods named .\\-initWithData:. found" "" { target *-*-* } .-1 } */
35 /* { dg-message "using .\\-\\(id\\)initWithData:\\(TestsuiteObject \\*\\)data." "" { target *-*-* } MyObject_initWithData } */
36 /* { dg-message "also found .\\-\\(id\\)initWithData:\\(id <MyObject, MyCoding>\\)data." "" { target *-*-* } MyCoding_initWithData } */
37 /* { dg-message "also found .\\-\\(id\\)initWithData:\\(int\\)data." "" { target *-*-* } SomeOther_initWithData } */
39 /* The following warning is a consequence of picking the "wrong" method signature. */
40 /* { dg-warning "passing argument 1 of .initWithData:. from distinct Objective\\-C type" "" { target *-*-* } result_init } */