1// RUN: %clang_cc1 -fobjc-arc -fsyntax-only -verify -Wselector-type-mismatch %s
2
3extern Class object_getClass(id);
4
5__attribute__((objc_root_class))
6@interface Root
7- (Class)class;
8+ (void)directMethod __attribute__((objc_direct)); // expected-note {{direct method 'directMethod' declared here}}
9+ (void)anotherDirectMethod __attribute__((objc_direct));
10@end
11
12@implementation Root
13- (Class)class
14{
15  return object_getClass(self);
16}
17+ (void)directMethod {
18}
19+ (void)anotherDirectMethod {
20  [self directMethod]; // this should not warn
21}
22+ (void)regularMethod {
23  [self directMethod];        // this should not warn
24  [self anotherDirectMethod]; // this should not warn
25}
26- (void)regularInstanceMethod {
27  [[self class] directMethod]; // expected-error {{messaging a Class with a method that is possibly direct}}
28}
29@end
30
31@interface Sub : Root
32@end
33
34@implementation Sub
35+ (void)foo {
36  [self directMethod]; // this should not warn
37}
38@end
39
40__attribute__((objc_root_class))
41@interface Other
42@end
43
44@implementation Other
45+ (void)bar {
46  [self directMethod]; // expected-error {{no known class method for selector 'directMethod'}}
47}
48@end
49