1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
2 /* { dg-do compile } */
6 /* Test that @optional for @protocol works. */
12 + (int)optionalClassMethod;
13 - (int)optionalMethod;
16 @interface MyRootClass <MyProtocol>
19 /* The implementation implements both the @required methods, but none
20 of the @optional ones. There should be no warnings as the
21 @optional methods are optional. ;-) */
22 @implementation MyRootClass
33 int function (id <MyProtocol> object1,
36 /* Test that there are no warnings if you try to use an @optional
37 method with an object of the class. */
40 i += [object1 method];
41 i += [object2 method];
42 i += [MyRootClass classMethod];
43 i += [object1 optionalMethod];
44 i += [object2 optionalMethod];
45 i += [MyRootClass optionalClassMethod];