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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
// RUN: clang -cc1 -emit-llvm -o %t %s
int printf(const char *, ...);
@interface Root
-(id) alloc;
-(id) init;
@end
// Property above methods...
@interface Top0 : Root
@property(getter=_getX,setter=_setX:) int x;
@end
@interface Bot0 : Top0
-(int) x;
-(void) setX: (int) arg;
@end
@implementation Top0
-(int) _getX {
printf("-[ Top0 _getX ]\n");
return 0;
}
-(void) _setX: (int) arg {
printf("-[ Top0 _setX: %d ]\n", arg);
}
@end
@implementation Bot0
-(int) x {
printf("-[ Bot0 _getX ]\n");
return 0;
}
-(void) setX: (int) arg {
printf("-[ Bot0 _setX: %d ]\n", arg);
}
@end
// Methods above property...
@interface Top1 : Root
-(int) x;
-(void) setX: (int) arg;
@end
@interface Bot1 : Top1
@property(getter=_getX,setter=_setX:) int x;
@end
@implementation Top1
-(int) x {
printf("-[ Top1 x ]\n");
return 0;
}
-(void) setX: (int) arg {
printf("-[ Top1 setX: %d ]\n", arg);
}
@end
@implementation Bot1
-(int) _getX {
printf("-[ Bot1 _getX ]\n");
return 0;
}
-(void) _setX: (int) arg {
printf("-[ Bot1 _setX: %d ]\n", arg);
}
@end
// Mixed setter & getter (variant 1)
@interface Top2 : Root
-(int) x;
-(void) _setX: (int) arg;
@end
@interface Bot2 : Top2
@property(getter=_getX,setter=_setX:) int x;
@end
@implementation Top2
-(int) x {
printf("-[ Top2 x ]\n");
return 0;
}
-(void) _setX: (int) arg {
printf("-[ Top2 _setX: %d ]\n", arg);
}
@end
@implementation Bot2
-(int) _getX {
printf("-[ Bot2 _getX ]\n");
return 0;
}
-(void) setX: (int) arg {
printf("-[ Bot2 setX: %d ]\n", arg);
}
@end
// Mixed setter & getter (variant 2)
@interface Top3 : Root
-(int) _getX;
-(void) setX: (int) arg;
@end
@interface Bot3 : Top3
@property(getter=_getX,setter=_setX:) int x;
@end
@implementation Top3
-(int) _getX {
printf("-[ Top3 _getX ]\n");
return 0;
}
-(void) setX: (int) arg {
printf("-[ Top3 setX: %d ]\n", arg);
}
@end
@implementation Bot3
-(int) x {
printf("-[ Bot3 x ]\n");
return 0;
}
-(void) _setX: (int) arg {
printf("-[ Bot3 _setX: %d ]\n", arg);
}
@end
// Mixed setter & getter (variant 3)
@interface Top4 : Root
@property(getter=_getX,setter=_setX:) int x;
@end
@interface Bot4 : Top4
-(int) _getX;
-(void) setX: (int) arg;
@end
@implementation Top4
-(int) x {
printf("-[ Top4 x ]\n");
return 0;
}
-(void) _setX: (int) arg {
printf("-[ Top4 _setX: %d ]\n", arg);
}
@end
@implementation Bot4
-(int) _getX {
printf("-[ Bot4 _getX ]\n");
return 0;
}
-(void) setX: (int) arg {
printf("-[ Bot4 setX: %d ]\n", arg);
}
@end
// Mixed setter & getter (variant 4)
@interface Top5 : Root
@property(getter=_getX,setter=_setX:) int x;
@end
@interface Bot5 : Top5
-(int) x;
-(void) _setX: (int) arg;
@end
@implementation Top5
-(int) _getX {
printf("-[ Top5 _getX ]\n");
return 0;
}
-(void) setX: (int) arg {
printf("-[ Top5 setX: %d ]\n", arg);
}
@end
@implementation Bot5
-(int) x {
printf("-[ Bot5 x ]\n");
return 0;
}
-(void) _setX: (int) arg {
printf("-[ Bot5 _setX: %d ]\n", arg);
}
@end
// Mixed level calls (variant 1)
@interface Top6 : Root
-(int) x;
@end
@interface Bot6 : Top6
-(void) setX: (int) arg;
@end
@implementation Top6
-(int) x {
printf("-[ Top6 x ]\n");
return 0;
}
@end
@implementation Bot6
-(void) setX: (int) arg {
printf("-[ Bot5 setX: %d ]\n", arg);
}
@end
// Mixed level calls (variant 1)
@interface Top7 : Root
-(void) setX: (int) arg;
@end
@interface Bot7 : Top7
-(int) x;
@end
@implementation Top7
-(void) setX: (int) arg {
printf("-[ Top7 setX: %d ]\n", arg);
}
@end
@implementation Bot7
-(int) x {
printf("-[ Bot7 x ]\n");
return 0;
}
@end
//
// FIXME: Two more (thats it?) interesting cases. Method access on
// getter w/o setter and method access on setter w/o getter.
int main() {
#define test(N) { \
Bot##N *ob = [[Bot##N alloc] init]; \
int x = ob.x; \
ob.x = 10; }
test(0);
test(1);
test(2);
test(3);
test(4);
test(5);
// test(6);
// test(7);
return 0;
}
|