Skip to content

Commit 2e7b4ad

Browse files
committed
Make eq/ne infix operators
1 parent 6a2663b commit 2e7b4ad

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
@@ -1285,6 +1285,10 @@ class Definitions {
12851285
else parents
12861286
}
12871287

1288+
/** Is synthesized symbol with alphanumeric name allowed to be used as an infix operator? */
1289+
def isInfix(sym: Symbol)(implicit ctx: Context): Boolean =
1290+
(sym eq Object_eq) || (sym eq Object_ne)
1291+
12881292
// ----- primitive value class machinery ------------------------------------------
12891293

12901294
/** 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
@@ -682,6 +682,7 @@ trait Checking {
682682
case Ident(name: SimpleName)
683683
if !name.exists(isOperatorPart) &&
684684
!app.symbol.hasAnnotation(defn.InfixAnnot) &&
685+
!defn.isInfix(app.symbol) &&
685686
!app.symbol.maybeOwner.is(Scala2x) &&
686687
!infixOKSinceFollowedBy(tree.right) &&
687688
ctx.settings.strict.value =>

0 commit comments

Comments
 (0)