Skip to content

Commit a01601e

Browse files
committed
Make eq/ne infix operators
1 parent c39209b commit a01601e

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,10 @@ class Definitions {
12781278
if (isTupleClass(cls) || cls == UnitClass) parents :+ syntheticParent(tparams) else parents
12791279
}
12801280

1281+
/** Is synthesized symbol with alphanumeric name allowed to be used as an infix operator? */
1282+
def isInfix(sym: Symbol)(implicit ctx: Context): Boolean =
1283+
(sym eq Object_eq) || (sym eq Object_ne)
1284+
12811285
// ----- primitive value class machinery ------------------------------------------
12821286

12831287
/** This class would also be obviated by the implicit function type design */

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ trait Checking {
675675
case Ident(name: SimpleName)
676676
if !name.exists(isOperatorPart) &&
677677
!app.symbol.hasAnnotation(defn.InfixAnnot) &&
678+
!defn.isInfix(app.symbol) &&
678679
!app.symbol.maybeOwner.is(Scala2x) &&
679680
!infixOKSinceFollowedBy(tree.right) &&
680681
ctx.settings.strict.value =>

0 commit comments

Comments
 (0)