Skip to content

Commit a9ef28c

Browse files
committed
Rename Eq -> Eql
Eq is already used with a slightly different meaning as a unary typeclass, e.g. cats.Eq.
1 parent 7c49b44 commit a9ef28c

File tree

21 files changed

+95
-104
lines changed

21 files changed

+95
-104
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,11 @@ class Definitions {
734734
lazy val TastyReflectionModule: TermSymbol = ctx.requiredModule("scala.tasty.Reflection")
735735
lazy val TastyReflection_macroContext: TermSymbol = TastyReflectionModule.requiredMethod("macroContext")
736736

737-
lazy val EqType: TypeRef = ctx.requiredClassRef("scala.Eq")
738-
def EqClass(implicit ctx: Context): ClassSymbol = EqType.symbol.asClass
739-
def EqModule(implicit ctx: Context): Symbol = EqClass.companionModule
737+
lazy val EqlType: TypeRef = ctx.requiredClassRef("scala.Eql")
738+
def EqlClass(implicit ctx: Context): ClassSymbol = EqlType.symbol.asClass
739+
def EqlModule(implicit ctx: Context): Symbol = EqlClass.companionModule
740740

741-
def Eq_eqAny(implicit ctx: Context): TermSymbol = EqModule.requiredMethod(nme.eqAny)
741+
def Eql_eqlAny(implicit ctx: Context): TermSymbol = EqlModule.requiredMethod(nme.eqlAny)
742742

743743
lazy val NotType: TypeRef = ctx.requiredClassRef("scala.implicits.Not")
744744
def NotClass(implicit ctx: Context): ClassSymbol = NotType.symbol.asClass

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import collection.mutable.ListBuffer
6767
*/
6868
object Denotations {
6969

70-
implicit def eqDenotation: Eq[Denotation, Denotation] = Eq.derived
70+
implicit def eqDenotation: Eql[Denotation, Denotation] = Eql.derived
7171

7272
/** A PreDenotation represents a group of single denotations or a single multi-denotation
7373
* It is used as an optimization to avoid forming MultiDenotations too eagerly.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object Names {
2525
def toTermName: TermName
2626
}
2727

28-
implicit def eqName: Eq[Name, Name] = Eq.derived
28+
implicit def eqName: Eql[Name, Name] = Eql.derived
2929

3030
/** A common superclass of Name and Symbol. After bootstrap, this should be
3131
* just the type alias Name | Symbol

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ object StdNames {
418418
val equals_ : N = "equals"
419419
val error: N = "error"
420420
val eval: N = "eval"
421-
val eqAny: N = "eqAny"
421+
val eqlAny: N = "eqlAny"
422422
val ex: N = "ex"
423423
val experimental: N = "experimental"
424424
val f: N = "f"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ trait Symbols { this: Context =>
406406

407407
object Symbols {
408408

409-
implicit def eqSymbol: Eq[Symbol, Symbol] = Eq.derived
409+
implicit def eqSymbol: Eql[Symbol, Symbol] = Eql.derived
410410

411411
/** Tree attachment containing the identifiers in a tree as a sorted array */
412412
val Ids: Property.Key[Array[String]] = new Property.Key

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ object Types {
4040

4141
@sharable private[this] var nextId = 0
4242

43-
implicit def eqType: Eq[Type, Type] = Eq.derived
43+
implicit def eqType: Eql[Type, Type] = Eql.derived
4444

4545
/** Main class representing types.
4646
*

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -699,18 +699,18 @@ trait Implicits { self: Typer =>
699699
if (ctx.inInlineMethod || enclosingInlineds.nonEmpty) ref(defn.TastyReflection_macroContext)
700700
else EmptyTree
701701

702-
/** If `formal` is of the form Eq[T, U], try to synthesize an
703-
* `Eq.eqAny[T, U]` as solution.
702+
/** If `formal` is of the form Eql[T, U], try to synthesize an
703+
* `Eql.eqlAny[T, U]` as solution.
704704
*/
705705
def synthesizedEq(formal: Type)(implicit ctx: Context): Tree = {
706706

707707
/** Is there an `Eql[T, T]` instance, assuming -strictEquality? */
708708
def hasEq(tp: Type)(implicit ctx: Context): Boolean = {
709-
val inst = inferImplicitArg(defn.EqType.appliedTo(tp, tp), span)
709+
val inst = inferImplicitArg(defn.EqlType.appliedTo(tp, tp), span)
710710
!inst.isEmpty && !inst.tpe.isError
711711
}
712712

713-
/** Can we assume the eqAny instance for `tp1`, `tp2`?
713+
/** Can we assume the eqlAny instance for `tp1`, `tp2`?
714714
* This is the case if assumedCanEqual(tp1, tp2), or
715715
* one of `tp1`, `tp2` has a reflexive `Eql` instance.
716716
*/
@@ -756,7 +756,7 @@ trait Implicits { self: Typer =>
756756
||
757757
!strictEquality &&
758758
ctx.test(implicit ctx => validEqAnyArgs(arg1, arg2)))
759-
ref(defn.Eq_eqAny).appliedToTypes(args).withSpan(span)
759+
ref(defn.Eql_eqlAny).appliedToTypes(args).withSpan(span)
760760
else EmptyTree
761761
case _ =>
762762
EmptyTree
@@ -817,7 +817,7 @@ trait Implicits { self: Typer =>
817817
trySpecialCase(defn.QuotedTypeClass, synthesizedTypeTag,
818818
trySpecialCase(defn.GenericClass, synthesizedGeneric,
819819
trySpecialCase(defn.TastyReflectionClass, synthesizedTastyContext,
820-
trySpecialCase(defn.EqClass, synthesizedEq,
820+
trySpecialCase(defn.EqlClass, synthesizedEq,
821821
trySpecialCase(defn.ValueOfClass, synthesizedValueOf, failed))))))
822822
}
823823
}
@@ -963,8 +963,8 @@ trait Implicits { self: Typer =>
963963
/** Check that equality tests between types `ltp` and `rtp` make sense */
964964
def checkCanEqual(ltp: Type, rtp: Type, span: Span)(implicit ctx: Context): Unit =
965965
if (!ctx.isAfterTyper && !assumedCanEqual(ltp, rtp)) {
966-
val res = implicitArgTree(defn.EqType.appliedTo(ltp, rtp), span)
967-
implicits.println(i"Eq witness found for $ltp / $rtp: $res: ${res.tpe}")
966+
val res = implicitArgTree(defn.EqlType.appliedTo(ltp, rtp), span)
967+
implicits.println(i"Eql witness found for $ltp / $rtp: $res: ${res.tpe}")
968968
}
969969

970970
/** Find an implicit parameter or conversion.
@@ -1032,7 +1032,7 @@ trait Implicits { self: Typer =>
10321032
if (argument.isEmpty) f(resultType) else ViewProto(f(argument.tpe.widen), f(resultType))
10331033
// Not clear whether we need to drop the `.widen` here. All tests pass with it in place, though.
10341034

1035-
private def isCoherent = pt.isRef(defn.EqClass)
1035+
private def isCoherent = pt.isRef(defn.EqlClass)
10361036

10371037
private val cmpContext = nestedContext()
10381038
private val cmpCandidates = (c1: Candidate, c2: Candidate) => compare(c1.ref, c2.ref, c1.level, c2.level)(cmpContext)

compiler/src/dotty/tools/dotc/util/SourceFile.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class SourceFile(val file: AbstractFile, computeContent: => Array[Char]) extends
190190
}
191191
}
192192
object SourceFile {
193-
implicit def eqSource: Eq[SourceFile, SourceFile] = Eq.derived
193+
implicit def eqSource: Eql[SourceFile, SourceFile] = Eql.derived
194194

195195
implicit def fromContext(implicit ctx: Context): SourceFile = ctx.source
196196

compiler/test-resources/repl/i4184

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ scala> object foo { class Foo }
22
// defined object foo
33
scala> object bar { class Foo }
44
// defined object bar
5-
scala> implicit def eqFoo: Eq[foo.Foo, foo.Foo] = Eq.derived
6-
def eqFoo: Eq[foo.Foo, foo.Foo]
5+
scala> implicit def eqFoo: Eql[foo.Foo, foo.Foo] = Eql.derived
6+
def eqFoo: Eql[foo.Foo, foo.Foo]
77
scala> object Bar { new foo.Foo == new bar.Foo }
88
1 | object Bar { new foo.Foo == new bar.Foo }
99
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

docs/docs/reference/enums/desugarEnums.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,6 @@ map into case classes or vals.
134134
where `n` is the ordinal number of the case in the companion object,
135135
starting from 0.
136136

137-
### Equality
138-
139-
An `enum` type contains a `scala.Eq` instance that restricts values of the `enum` type to
140-
be compared only to other values of the same enum type. Furtermore, generic
141-
`enum` types are comparable only if their type arguments are. For instance the
142-
`Option` enum type will get the following definition in its companion object:
143-
144-
implicit def eqOption[T, U](implicit ev1: Eq[T, U]): Eq[Option[T], Option[U]] = Eq
145-
146137
### Translation of Enumerations
147138

148139
Non-generic enums `E` that define one or more singleton cases

0 commit comments

Comments
 (0)