1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
3 @interface RandomObject {
10 - (void)nothingInteresting;
13 @protocol Test2Protocol
15 - (id)alloc2; // expected-note 2 {{method 'alloc2' declared here}}
18 @implementation RandomObject
20 Class<TestProtocol> c = [c alloc]; // expected-warning {{class method '+alloc' not found (return type defaults to 'id')}}
21 Class<Test2Protocol> c1 = [c1 alloc2]; // expected-warning {{instance method 'alloc2' found instead of class method 'alloc2'}}
22 Class<Test2Protocol> c2 = [c2 alloc]; // ok
24 + (id)alloc { return 0; }
29 Class<TestProtocol> c = [c alloc]; // expected-warning {{class method '+alloc' not found (return type defaults to 'id')}}
30 Class<Test2Protocol> c1 = [c1 alloc2]; // expected-warning {{instance method 'alloc2' found instead of class method 'alloc2'}}
31 Class<Test2Protocol> c2 = [c2 alloc]; // ok
37 - (int)respondsToSelector:(SEL)aSelector;
41 __attribute__((objc_root_class))
42 @interface NSObject <NSObject>
48 - (void)otherInstanceMethod; // expected-note {{method 'otherInstanceMethod' declared here}}
52 @protocol MyProto <NSObject, OtherProto>
55 void allowInstanceMethodsFromRootProtocols(Class<MyProto> c) {
56 [c respondsToSelector: @selector(instanceMethod)]; // no warning
57 [c otherInstanceMethod]; // expected-warning {{instance method 'otherInstanceMethod' found instead of class method 'otherInstanceMethod'}}