1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wselector-type-mismatch %s
@protocol Proto
- (void)protoMethod; // expected-note {{previous declaration is here}}
+ (void)classProtoMethod; // expected-note {{previous declaration is here}}
@end
@protocol ProtoDirectFail
- (void)protoMethod __attribute__((objc_direct)); // expected-error {{'objc_direct' attribute cannot be applied to methods declared in an Objective-C protocol}}
+ (void)classProtoMethod __attribute__((objc_direct)); // expected-error {{'objc_direct' attribute cannot be applied to methods declared in an Objective-C protocol}}
@end
__attribute__((objc_root_class))
@interface Root
- (void)unavailableInChild;
- (void)rootRegular; // expected-note {{previous declaration is here}}
+ (void)classRootRegular; // expected-note {{previous declaration is here}}
- (void)rootDirect __attribute__((objc_direct)); // expected-note {{previous declaration is here}};
+ (void)classRootDirect __attribute__((objc_direct)); // expected-note {{previous declaration is here}};
- (void)otherRootDirect __attribute__((objc_direct)); // expected-note {{direct method 'otherRootDirect' declared here}}
+ (void)otherClassRootDirect __attribute__((objc_direct)); // expected-note {{direct method 'otherClassRootDirect' declared here}}
+ (void)otherOtherClassRootDirect __attribute__((objc_direct)); // expected-note {{direct method 'otherOtherClassRootDirect' declared here}}
- (void)notDirectInIface; // expected-note {{previous declaration is here}}
+ (void)classNotDirectInIface; // expected-note {{previous declaration is here}}
@end
__attribute__((objc_direct_members))
@interface Root ()
- (void)rootExtensionDirect; // expected-note {{previous declaration is here}}
+ (void)classRootExtensionDirect; // expected-note {{previous declaration is here}}
@end
__attribute__((objc_direct_members))
@interface Root(Direct)
- (void)rootCategoryDirect; // expected-note {{previous declaration is here}}
+ (void)classRootCategoryDirect; // expected-note {{previous declaration is here}}
@end
@interface Root ()
- (void)rootExtensionRegular; // expected-note {{previous declaration is here}}
+ (void)classRootExtensionRegular; // expected-note {{previous declaration is here}}
- (void)rootExtensionDirect2 __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+ (void)classRootExtensionDirect2 __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
@end
@interface Root (Direct2)
- (void)rootCategoryRegular; // expected-note {{previous declaration is here}}
+ (void)classRootCategoryRegular; // expected-note {{previous declaration is here}}
- (void)rootCategoryDirect2 __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+ (void)classRootCategoryDirect2 __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
@end
__attribute__((objc_direct_members))
@interface SubDirectMembers : Root
@property int foo; // expected-note {{previous declaration is here}}
- (void)unavailableInChild __attribute__((unavailable)); // should not warn
- (instancetype)init;
@end
@interface Sub : Root <Proto>
/* invalid overrides with directs */
- (void)rootRegular __attribute__((objc_direct)); // expected-error {{methods that override superclass methods cannot be direct}}
+ (void)classRootRegular __attribute__((objc_direct)); // expected-error {{methods that override superclass methods cannot be direct}}
- (void)protoMethod __attribute__((objc_direct)); // expected-error {{methods that implement protocol requirements cannot be direct}}
+ (void)classProtoMethod __attribute__((objc_direct)); // expected-error {{methods that implement protocol requirements cannot be direct}}
- (void)rootExtensionRegular __attribute__((objc_direct)); // expected-error {{methods that override superclass methods cannot be direct}}
+ (void)classRootExtensionRegular __attribute__((objc_direct)); // expected-error {{methods that override superclass methods cannot be direct}}
- (void)rootCategoryRegular __attribute__((objc_direct)); // expected-error {{methods that override superclass methods cannot be direct}}
+ (void)classRootCategoryRegular __attribute__((objc_direct)); // expected-error {{methods that override superclass methods cannot be direct}}
/* invalid overrides of directs */
- (void)rootDirect; // expected-error {{cannot override a method that is declared direct by a superclass}}
+ (void)classRootDirect; // expected-error {{cannot override a method that is declared direct by a superclass}}
- (void)rootExtensionDirect; // expected-error {{cannot override a method that is declared direct by a superclass}}
+ (void)classRootExtensionDirect; // expected-error {{cannot override a method that is declared direct by a superclass}}
- (void)rootExtensionDirect2; // expected-error {{cannot override a method that is declared direct by a superclass}}
+ (void)classRootExtensionDirect2; // expected-error {{cannot override a method that is declared direct by a superclass}}
- (void)rootCategoryDirect; // expected-error {{cannot override a method that is declared direct by a superclass}}
+ (void)classRootCategoryDirect; // expected-error {{cannot override a method that is declared direct by a superclass}}
- (void)rootCategoryDirect2; // expected-error {{cannot override a method that is declared direct by a superclass}}
+ (void)classRootCategoryDirect2; // expected-error {{cannot override a method that is declared direct by a superclass}}
@end
__attribute__((objc_direct_members))
@implementation Root
- (void)unavailableInChild {
}
- (void)rootRegular {
}
+ (void)classRootRegular {
}
- (void)rootDirect {
}
+ (void)classRootDirect {
}
- (void)otherRootDirect {
}
+ (void)someRootDirectMethod { // expected-note {{direct method 'someRootDirectMethod' declared here}}
}
+ (void)otherClassRootDirect {
[self someRootDirectMethod]; // expected-error {{messaging a Class with a method that is possibly direct}}
}
+ (void)otherOtherClassRootDirect {
}
- (void)rootExtensionDirect {
}
+ (void)classRootExtensionDirect {
}
- (void)rootExtensionRegular {
}
+ (void)classRootExtensionRegular {
}
- (void)rootExtensionDirect2 {
}
+ (void)classRootExtensionDirect2 {
}
- (void)notDirectInIface __attribute__((objc_direct)) // expected-error {{direct method implementation was previously declared not direct}}
{
}
+ (void)classNotDirectInIface __attribute__((objc_direct)) // expected-error {{direct method implementation was previously declared not direct}}
{
}
- (void)direct1 { // expected-note {{direct method 'direct1' declared here}}
}
- (void)direct2 { // expected-note {{direct method 'direct2' declared here}}
}
@end
@interface Foo : Root
- (id)directMismatch1; // expected-note {{using}}
- (id)directMismatch2; // expected-note {{method 'directMismatch2' declared here}}
@end
@interface Bar : Root
- (void)directMismatch1 __attribute__((objc_direct)); // expected-note {{also found}}
- (void)directMismatch2 __attribute__((objc_direct)); // expected-note {{method 'directMismatch2' declared here}}
@end
@interface ValidSub : Root
@end
@implementation ValidSub
- (void)someValidSubMethod {
[super otherRootDirect]; // expected-error {{messaging super with a direct method}}
}
+ (void)someValidSubMethod {
[super otherOtherClassRootDirect]; // expected-error {{messaging super with a direct method}}
}
@end
@implementation SubDirectMembers
@dynamic foo; // expected-error {{direct property cannot be @dynamic}}
- (instancetype)init {
return self;
}
@end
extern void callMethod(id obj, Class cls);
extern void useSel(SEL sel);
void callMethod(id obj, Class cls) {
[Root otherClassRootDirect];
[cls otherClassRootDirect]; // expected-error {{messaging a Class with a method that is possibly direct}}
[obj direct1]; // expected-error {{messaging unqualified id with a method that is possibly direct}}
[(Root *)obj direct1];
[obj directMismatch1]; // expected-warning {{multiple methods named 'directMismatch1' found}}
useSel(@selector(direct2)); // expected-error {{@selector expression formed with direct selector 'direct2'}}
useSel(@selector(directMismatch2)); // expected-warning {{several methods with selector 'directMismatch2' of mismatched types are found for the @selector expression}}
}
|