Skip to content

Remove the Eql instance for Proxy. #10407

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 2 commits into from
Nov 20, 2020
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
9 changes: 3 additions & 6 deletions library/src/scala/Eql.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scala

import annotation.implicitNotFound
import scala.collection.{GenSeq, Set}
import scala.collection.{Seq, Set}

/** A marker trait indicating that values of type `L` can be compared to values of type `R`. */
@implicitNotFound("Values of types ${L} and ${R} cannot be compared with == or !=")
Expand All @@ -27,11 +27,8 @@ object Eql {
given eqlString as Eql[String, String] = derived

// The next three definitions can go into the companion objects of classes
// Seq, Set, and Proxy. For now they are here in order not to have to touch the
// Seq and Set. For now they are here in order not to have to touch the
// source code of these classes
given eqlSeq[T, U](using eq: Eql[T, U]) as Eql[GenSeq[T], GenSeq[U]] = derived
given eqlSeq[T, U](using eq: Eql[T, U]) as Eql[Seq[T], Seq[U]] = derived
given eqlSet[T, U](using eq: Eql[T, U]) as Eql[Set[T], Set[U]] = derived

// true asymmetry, modeling the (somewhat problematic) nature of equals on Proxies
given eqlProxy as Eql[Proxy, AnyRef] = derived
}
8 changes: 0 additions & 8 deletions tests/neg/equality.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ object equality {
implicit def eqNum: Eql[Num, Num] = Eql.derived
implicit def eqOption[T, U](implicit e: Eql[T, U]): Eql[Option[T], Option[U]] = Eql.derived

case class PString(a: String) extends Proxy {
def self = a
}

/*
implicit def eqString: Eql[String, String] = Eql.derived
implicit def eqInt: Eql[Int, Int] = Eql.derived
Expand Down Expand Up @@ -84,9 +80,6 @@ object equality {
i == bi
bi == i

val ps = PString("hello")
ps == "world"

n match {
case None => // error
}
Expand All @@ -110,7 +103,6 @@ object equality {
1 == "abc" // error
"abc" == bi // error
bi == "abc" // error
"world" == ps // error

val s1 = Set(1, 2, 3)
val s2 = Set()
Expand Down
2 changes: 1 addition & 1 deletion tests/run/proxy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ object Test extends App {

val label = Bippy("bippy!")
println(label == label)
println(label == "bippy!")
println((label: Any) == ("bippy!": Any))
}