1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
4 @interface RandomObject {
10 @protocol TestProtocol
11 - (void)nothingInteresting;
14 @protocol Test2Protocol
16 - (id)alloc2; // expected-note 2 {{method 'alloc2' declared here}}
19 @implementation RandomObject
21 Class<TestProtocol> c = [c alloc]; // expected-warning {{class method '+alloc' not found (return type defaults to 'id')}}
22 Class<Test2Protocol> c1 = [c1 alloc2]; // expected-warning {{instance method 'alloc2' found instead of class method 'alloc2'}}
23 Class<Test2Protocol> c2 = [c2 alloc]; // ok
25 + (id)alloc { return 0; }
30 Class<TestProtocol> c = [c alloc]; // expected-warning {{class method '+alloc' not found (return type defaults to 'id')}}
31 Class<Test2Protocol> c1 = [c1 alloc2]; // expected-warning {{instance method 'alloc2' found instead of class method 'alloc2'}}
32 Class<Test2Protocol> c2 = [c2 alloc]; // ok
40 - (int)respondsToSelector:(SEL)aSelector;
44 __attribute__((objc_root_class))
45 @interface NSObject <NSObject>
51 - (void)otherInstanceMethod; // expected-note {{method 'otherInstanceMethod' declared here}}
55 @protocol MyProto <NSObject, OtherProto>
58 void allowInstanceMethodsFromRootProtocols(Class<MyProto> c) {
59 [c respondsToSelector: @selector(instanceMethod)]; // no warning
60 [c otherInstanceMethod]; // expected-warning {{instance method 'otherInstanceMethod' found instead of class method 'otherInstanceMethod'}}