@@ -214,29 +214,125 @@ extension S0 {
214
214
}
215
215
216
216
struct S1 {
217
- func %%% ( lhs: S0 , rhs: S0 ) -> S0 { return lhs } // expected-error{{operator '%%%' declared in type 'S1' must be 'static'}}{{3-3=static }}
217
+ func %%% ( lhs: S1 , rhs: S1 ) -> S1 { return lhs } // expected-error{{operator '%%%' declared in type 'S1' must be 'static'}}{{3-3=static }}
218
218
}
219
219
220
220
extension S1 {
221
- func %%%% ( lhs: S0 , rhs: S0 ) -> S0 { return lhs } // expected-error{{operator '%%%%' declared in type 'S1' must be 'static'}}{{3-3=static }}
221
+ func %%%% ( lhs: S1 , rhs: S1 ) -> S1 { return lhs } // expected-error{{operator '%%%%' declared in type 'S1' must be 'static'}}{{3-3=static }}
222
222
}
223
223
224
224
class C0 {
225
- static func %%% ( lhs: S0 , rhs: S0 ) -> S0 { return lhs }
225
+ static func %%% ( lhs: C0 , rhs: C0 ) -> C0 { return lhs }
226
226
}
227
227
228
228
class C1 {
229
- final func %%% ( lhs: S0 , rhs: S0 ) -> S0 { return lhs }
229
+ final func %%% ( lhs: C1 , rhs: C1 ) -> C1 { return lhs }
230
230
}
231
231
232
232
final class C2 {
233
- class func %%% ( lhs: S0 , rhs: S0 ) -> S0 { return lhs }
233
+ class func %%% ( lhs: C2 , rhs: C2 ) -> C2 { return lhs }
234
234
}
235
235
236
236
class C3 {
237
- class func %%% ( lhs: S0 , rhs: S0 ) -> S0 { return lhs } // expected-error{{operator '%%%' declared in non-final class 'C3' must be 'final'}}{{3-3=final }}
237
+ class func %%% ( lhs: C3 , rhs: C3 ) -> C3 { return lhs } // expected-error{{operator '%%%' declared in non-final class 'C3' must be 'final'}}{{3-3=final }}
238
238
}
239
239
240
240
class C4 {
241
- func %%% ( lhs: S0 , rhs: S0 ) -> S0 { return lhs } // expected-error{{operator '%%%' declared in type 'C4' must be 'static'}}{{3-3=static }}
241
+ func %%% ( lhs: C4 , rhs: C4 ) -> C4 { return lhs } // expected-error{{operator '%%%' declared in type 'C4' must be 'static'}}{{3-3=static }}
242
+ }
243
+
244
+ struct Unrelated { }
245
+
246
+ struct S2 {
247
+ static func %%% ( lhs: Unrelated , rhs: Unrelated ) -> Unrelated { }
248
+ // expected-error@-1{{member operator '%%%' must have at least one argument of type 'S2'}}
249
+
250
+ static func %%% ( lhs: Unrelated , rhs: Unrelated ) -> S2 { }
251
+ // expected-error@-1{{member operator '%%%' must have at least one argument of type 'S2'}}
252
+
253
+ static func %%% ( lhs: Unrelated , rhs: Unrelated ) -> S2 . Type { }
254
+ // expected-error@-1{{member operator '%%%' must have at least one argument of type 'S2'}}
255
+
256
+ // Okay: refers to S2
257
+ static func %%% ( lhs: S2 , rhs: Unrelated ) -> Unrelated { }
258
+ static func %%% ( lhs: inout S2 , rhs: Unrelated ) -> Unrelated { }
259
+ static func %%% ( lhs: S2 . Type , rhs: Unrelated ) -> Unrelated { }
260
+ static func %%% ( lhs: inout S2 . Type , rhs: Unrelated ) -> Unrelated { }
261
+ static func %%% ( lhs: Unrelated , rhs: S2 ) -> Unrelated { }
262
+ static func %%% ( lhs: Unrelated , rhs: inout S2 ) -> Unrelated { }
263
+ static func %%% ( lhs: Unrelated , rhs: S2 . Type ) -> Unrelated { }
264
+ static func %%% ( lhs: Unrelated , rhs: inout S2 . Type ) -> Unrelated { }
265
+ }
266
+
267
+ extension S2 {
268
+ static func %%%% ( lhs: Unrelated , rhs: Unrelated ) -> Unrelated { }
269
+ // expected-error@-1{{member operator '%%%%' must have at least one argument of type 'S2'}}
270
+
271
+ static func %%%% ( lhs: Unrelated , rhs: Unrelated ) -> S2 { }
272
+ // expected-error@-1{{member operator '%%%%' must have at least one argument of type 'S2'}}
273
+
274
+ static func %%%% ( lhs: Unrelated , rhs: Unrelated ) -> S2 . Type { }
275
+ // expected-error@-1{{member operator '%%%%' must have at least one argument of type 'S2'}}
276
+
277
+ // Okay: refers to S2
278
+ static func %%%% ( lhs: S2 , rhs: Unrelated ) -> Unrelated { }
279
+ static func %%%% ( lhs: inout S2 , rhs: Unrelated ) -> Unrelated { }
280
+ static func %%%% ( lhs: S2 . Type , rhs: Unrelated ) -> Unrelated { }
281
+ static func %%%% ( lhs: inout S2 . Type , rhs: Unrelated ) -> Unrelated { }
282
+ static func %%%% ( lhs: Unrelated , rhs: S2 ) -> Unrelated { }
283
+ static func %%%% ( lhs: Unrelated , rhs: inout S2 ) -> Unrelated { }
284
+ static func %%%% ( lhs: Unrelated , rhs: S2 . Type ) -> Unrelated { }
285
+ static func %%%% ( lhs: Unrelated , rhs: inout S2 . Type ) -> Unrelated { }
286
+ }
287
+
288
+ protocol P2 {
289
+ static func %%% ( lhs: Unrelated , rhs: Unrelated ) -> Unrelated
290
+ // expected-error@-1{{member operator '%%%' of protocol 'P2' must have at least one argument of type 'Self'}}
291
+
292
+ static func %%% ( lhs: Unrelated , rhs: Unrelated ) -> Self
293
+ // expected-error@-1{{member operator '%%%' of protocol 'P2' must have at least one argument of type 'Self'}}
294
+
295
+ static func %%% ( lhs: Unrelated , rhs: Unrelated ) -> Self . Type
296
+ // expected-error@-1{{member operator '%%%' of protocol 'P2' must have at least one argument of type 'Self'}}
297
+
298
+ // Okay: refers to Self
299
+ static func %%% ( lhs: Self , rhs: Unrelated ) -> Unrelated
300
+ static func %%% ( lhs: inout Self , rhs: Unrelated ) -> Unrelated
301
+ static func %%% ( lhs: Self . Type , rhs: Unrelated ) -> Unrelated
302
+ static func %%% ( lhs: inout Self . Type , rhs: Unrelated ) -> Unrelated
303
+ static func %%% ( lhs: Unrelated , rhs: Self ) -> Unrelated
304
+ static func %%% ( lhs: Unrelated , rhs: inout Self ) -> Unrelated
305
+ static func %%% ( lhs: Unrelated , rhs: Self . Type ) -> Unrelated
306
+ static func %%% ( lhs: Unrelated , rhs: inout Self . Type ) -> Unrelated
307
+ }
308
+
309
+ extension P2 {
310
+ static func %%%% ( lhs: Unrelated , rhs: Unrelated ) -> Unrelated { }
311
+ // expected-error@-1{{member operator '%%%%' of protocol 'P2' must have at least one argument of type 'Self'}}
312
+
313
+ static func %%%% ( lhs: Unrelated , rhs: Unrelated ) -> Self { }
314
+ // expected-error@-1{{member operator '%%%%' of protocol 'P2' must have at least one argument of type 'Self'}}
315
+
316
+ static func %%%% ( lhs: Unrelated , rhs: Unrelated ) -> Self . Type { }
317
+ // expected-error@-1{{member operator '%%%%' of protocol 'P2' must have at least one argument of type 'Self'}}
318
+
319
+ // Okay: refers to Self
320
+ static func %%%% ( lhs: Self , rhs: Unrelated ) -> Unrelated { }
321
+ static func %%%% ( lhs: inout Self , rhs: Unrelated ) -> Unrelated { }
322
+ static func %%%% ( lhs: Self . Type , rhs: Unrelated ) -> Unrelated { }
323
+ static func %%%% ( lhs: inout Self . Type , rhs: Unrelated ) -> Unrelated { }
324
+ static func %%%% ( lhs: Unrelated , rhs: Self ) -> Unrelated { }
325
+ static func %%%% ( lhs: Unrelated , rhs: inout Self ) -> Unrelated { }
326
+ static func %%%% ( lhs: Unrelated , rhs: Self . Type ) -> Unrelated { }
327
+ static func %%%% ( lhs: Unrelated , rhs: inout Self . Type ) -> Unrelated { }
328
+ }
329
+
330
+ protocol P3 {
331
+ // Okay: refers to P3
332
+ static func %%% ( lhs: P3 , rhs: Unrelated ) -> Unrelated
333
+ }
334
+
335
+ extension P3 {
336
+ // Okay: refers to P3
337
+ static func %%%% ( lhs: P3 , rhs: Unrelated ) -> Unrelated { }
242
338
}
0 commit comments