1 // RUN: %clang_cc1 -rewrite-objc %s -o - 2 3 typedef struct MyWidget { 4 int a; 5 } MyWidget; 6 7 MyWidget 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 43 int main(void) { 44 id view; 45 MyWidget *w = [Container elementForView: view]; 46 47 return 0; 48 } 49