Skip to content

Commit bec1174

Browse files
committed
Make eq/ne infix operators
1 parent 06310b3 commit bec1174

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
@@ -1287,6 +1287,10 @@ class Definitions {
12871287
else parents
12881288
}
12891289

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

12921296
/** 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
@@ -735,6 +735,7 @@ trait Checking {
735735
case Ident(name: SimpleName)
736736
if !name.exists(isOperatorPart) &&
737737
!app.symbol.hasAnnotation(defn.InfixAnnot) &&
738+
!defn.isInfix(app.symbol) &&
738739
!app.symbol.maybeOwner.is(Scala2x) &&
739740
!infixOKSinceFollowedBy(tree.right) &&
740741
ctx.settings.strict.value =>

0 commit comments

Comments
 (0)