blob: f90911b2cb0f0389b4a503831c5ee1abb53dc04d [file] [log] [blame]
Steve Naroffdd79d6f2008-03-12 02:07:40 +00001// RUN: clang -rewrite-test %s
Fariborz Jahanian6ff57c62007-12-07 18:47:10 +00002
3typedef struct MyWidget {
4 int a;
5} MyWidget;
6
7MyWidget gWidget = { 17 };
8
9@protocol MyProto
10- (MyWidget *)widget;
11@end
12
13@interface Foo
14@end
15
16@interface Bar: Foo <MyProto>
17@end
18
19@interface Container
20+ (MyWidget *)elementForView:(Foo *)view;
21@end
22
23@implementation Foo
24@end
25
26@implementation Bar
27- (MyWidget *)widget {
28 return &gWidget;
29}
30@end
31
32@implementation Container
33+ (MyWidget *)elementForView:(Foo *)view
34{
35 MyWidget *widget = (void*)0;
36 if (@protocol(MyProto)) {
37 widget = [(id <MyProto>)view widget];
38 }
39 return widget;
40}
41@end
42
43int main(void) {
44 id view;
45 MyWidget *w = [Container elementForView: view];
46
47 return 0;
48}