1 // RUN: %clang_cc1 -fsyntax-only -verify -Wselector-type-mismatch %s
3 @protocol ProtoDirectFail
4 @property(nonatomic, direct) int protoProperty; // expected-error {{'objc_direct' attribute cannot be applied to properties declared in an Objective-C protocol}}
7 __attribute__((objc_root_class))
9 @property(nonatomic, direct) int propertyWithNonDirectGetter; // expected-note {{previous declaration is here}}
10 - (int)propertyWithNonDirectGetter;
11 - (int)propertyWithNonDirectGetter2;
12 - (int)propertyWithNonDirectGetterInParent;
13 - (int)propertyWithNonDirectGetterInParent2;
15 @property(nonatomic, readonly, direct) int getDirect_setDynamic; // expected-note {{previous declaration is here}}
16 @property(nonatomic, readonly, direct) int getDirect_setDirect; // expected-note {{previous declaration is here}}
17 @property(nonatomic, readonly, direct) int getDirect_setDirectMembers; // expected-note {{previous declaration is here}}
19 @property(nonatomic, readonly) int getDynamic_setDirect;
20 @property(nonatomic, readonly) int getDynamic_setDirectMembers;
22 @property(nonatomic, readonly) int dynamicProperty;
23 @property(nonatomic, readonly) int synthDynamicProperty;
25 @property(nonatomic, readonly, direct) int directProperty; // expected-note {{previous declaration is here}}
26 @property(nonatomic, readonly, direct) int synthDirectProperty; // expected-note {{previous declaration is here}}
29 __attribute__((objc_direct_members))
32 @property(nonatomic) int propertyWithNonDirectGetter2; // expected-note {{previous declaration is here}}
34 @property(nonatomic, readwrite) int getDirect_setDirectMembers; // expected-note {{previous declaration is here}}
35 @property(nonatomic, readwrite) int getDynamic_setDirectMembers; // expected-note {{previous declaration is here}}
39 @property(nonatomic, readwrite) int getDirect_setDynamic;
40 @property(nonatomic, readwrite, direct) int getDirect_setDirect; // expected-note {{previous declaration is here}}
42 @property(nonatomic, readwrite, direct) int getDynamic_setDirect; // expected-note {{previous declaration is here}}
46 @property(nonatomic, direct) int propertyWithNonDirectGetterInParent; // expected-note {{previous declaration is here}}
48 - (int)propertyWithNonDirectGetter; // no error: legal override
49 - (int)propertyWithNonDirectGetter2; // no error: legal override
50 - (int)propertyWithNonDirectGetterInParent; // no error: legal override
51 - (int)propertyWithNonDirectGetterInParent2; // no error: legal override
55 __attribute__((objc_direct_members))
57 @property(nonatomic) int propertyWithNonDirectGetterInParent2; // expected-note {{previous declaration is here}}
60 // make sure that the `directness` of methods stuck,
61 // by observing errors trying to override the setter
62 @interface SubWitness : Sub
64 - (int)setPropertyWithNonDirectGetter:(int)value; // expected-error {{cannot override a method that is declared direct by a superclass}}
65 - (int)setPropertyWithNonDirectGetter2:(int)value; // expected-error {{cannot override a method that is declared direct by a superclass}}
66 - (int)setPropertyWithNonDirectGetterInParent:(int)value; // expected-error {{cannot override a method that is declared direct by a superclass}}
67 - (int)setPropertyWithNonDirectGetterInParent2:(int)value; // expected-error {{cannot override a method that is declared direct by a superclass}}
69 - (int)getDirect_setDynamic; // expected-error {{cannot override a method that is declared direct by a superclass}}
70 - (int)setGetDirect_setDynamic:(int)value;
71 - (int)getDirect_setDirect; // expected-error {{cannot override a method that is declared direct by a superclass}}
72 - (int)setGetDirect_setDirect:(int)value; // expected-error {{cannot override a method that is declared direct by a superclass}}
73 - (int)getDirect_setDirectMembers; // expected-error {{cannot override a method that is declared direct by a superclass}}
74 - (int)setGetDirect_setDirectMembers:(int)value; // expected-error {{cannot override a method that is declared direct by a superclass}}
76 - (int)getDynamic_setDirect;
77 - (int)setGetDynamic_setDirect:(int)value; // expected-error {{cannot override a method that is declared direct by a superclass}}
78 - (int)getDynamic_setDirectMembers;
79 - (int)setGetDynamic_setDirectMembers:(int)value; // expected-error {{cannot override a method that is declared direct by a superclass}}
82 __attribute__((objc_direct_members))
84 - (int)propertyWithNonDirectGetter {
87 - (int)propertyWithNonDirectGetter2 {
90 - (int)propertyWithNonDirectGetterInParent {
93 - (int)propertyWithNonDirectGetterInParent2 {
97 - (int)dynamicProperty {
100 - (int)directProperty {
106 - (int)propertyWithNonDirectGetter {
109 - (int)propertyWithNonDirectGetter2 {
113 - (int)dynamicProperty {
116 - (int)synthDynamicProperty {
120 - (int)directProperty { // expected-error {{cannot override a method that is declared direct by a superclass}}
123 - (int)synthDirectProperty { // expected-error {{cannot override a method that is declared direct by a superclass}}