Skip to content

chore: mark AnyRef::eq and AnyRef::ne as infix instead of special casing when emitting the warning #23252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ class Definitions {
@tu lazy val AnyRefAlias: TypeSymbol = enterAliasType(tpnme.AnyRef, ObjectType)
def AnyRefType: TypeRef = AnyRefAlias.typeRef

@tu lazy val Object_eq: TermSymbol = enterMethod(ObjectClass, nme.eq, methOfAnyRef(BooleanType), Final)
@tu lazy val Object_ne: TermSymbol = enterMethod(ObjectClass, nme.ne, methOfAnyRef(BooleanType), Final)
@tu lazy val Object_eq: TermSymbol = enterMethod(ObjectClass, nme.eq, methOfAnyRef(BooleanType), Final | Infix)
@tu lazy val Object_ne: TermSymbol = enterMethod(ObjectClass, nme.ne, methOfAnyRef(BooleanType), Final | Infix)
@tu lazy val Object_synchronized: TermSymbol = enterPolyMethod(ObjectClass, nme.synchronized_, 1,
pt => MethodType(List(pt.paramRefs(0)), pt.paramRefs(0)), Final)
@tu lazy val Object_clone: TermSymbol = enterMethod(ObjectClass, nme.clone_, MethodType(Nil, ObjectType), Protected)
Expand Down Expand Up @@ -2042,10 +2042,6 @@ class Definitions {
def hasProblematicGetClass(className: Name): Boolean =
HasProblematicGetClass.contains(className)

/** Is synthesized symbol with alphanumeric name allowed to be used as an infix operator? */
def isInfix(sym: Symbol)(using Context): Boolean =
(sym eq Object_eq) || (sym eq Object_ne)

@tu lazy val assumedTransparentNames: Map[Name, Set[Symbol]] =
// add these for now, until we had a chance to retrofit 2.13 stdlib
// we should do a more through sweep through it then.
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/core/SymUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ class SymUtils:
/** Is symbol assumed or declared as an infix symbol? */
def isDeclaredInfix(using Context): Boolean =
self.is(Infix)
|| defn.isInfix(self)
|| self.name.isUnapplyName
&& self.owner.is(Module)
&& self.owner.linkedClass.is(Case)
Expand Down
Loading