File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -4335,6 +4335,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
4335
4335
dc->getDeclaredInterfaceType ())
4336
4336
.fixItInsert (FD->getAttributeInsertionLoc (/* forModifier=*/ true ),
4337
4337
" static " );
4338
+
4339
+ FD->setStatic ();
4338
4340
} else {
4339
4341
TC.diagnose (FD->getLoc (), diag::nonfinal_operator_in_class,
4340
4342
operatorName, dc->getDeclaredInterfaceType ())
@@ -4350,6 +4352,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
4350
4352
dc->getDeclaredInterfaceType ())
4351
4353
.fixItInsert (FD->getAttributeInsertionLoc (/* forModifier=*/ true ),
4352
4354
" static " );
4355
+ FD->setStatic ();
4353
4356
}
4354
4357
} else if (!dc->isModuleScopeContext ()) {
4355
4358
TC.diagnose (FD, diag::operator_in_local_scope);
Original file line number Diff line number Diff line change @@ -406,6 +406,12 @@ class ApplyClassifier {
406
406
SmallVector<Expr*, 4 > args;
407
407
auto fnRef = AbstractFunction::decomposeApply (E, args);
408
408
409
+ // If any of the arguments didn't type check, fail.
410
+ for (auto arg : args) {
411
+ if (!arg->getType () || arg->getType ()->is <ErrorType>())
412
+ return Classification::forInvalidCode ();
413
+ }
414
+
409
415
// If we're applying more arguments than the natural argument
410
416
// count, then this is a call to the opaque value returned from
411
417
// the function.
Original file line number Diff line number Diff line change @@ -336,3 +336,20 @@ extension P3 {
336
336
// Okay: refers to P3
337
337
static func %%%% ( lhs: P3 , rhs: Unrelated ) -> Unrelated { }
338
338
}
339
+
340
+ // rdar://problem/27940842 - recovery with a non-static '=='.
341
+ class C5 {
342
+ func == ( lhs: C5 , rhs: C5 ) -> Bool { return false } // expected-error{{operator '==' declared in type 'C5' must be 'static'}}
343
+
344
+ func test1( x: C5 ) {
345
+ _ = x == x
346
+ }
347
+ }
348
+
349
+ class C6 {
350
+ static func == ( lhs: C6 , rhs: C6 ) -> Bool { return false }
351
+
352
+ func test1( x: C6 ) {
353
+ if x == x && x = x { } // expected-error{{cannot assign to value: '&&' returns immutable value}}
354
+ }
355
+ }
You can’t perform that action at this time.
0 commit comments