blob: 204f34a916a075998f349915be4c075fb4f5d1cb [file] [log] [blame]
Steve Naroffb29b4272008-04-14 22:03:09 +00001// RUN: clang -rewrite-objc %s -o=-
Fariborz Jahanian36ee2cb2007-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}