diff options
author | Martin Odersky <odersky@gmail.com> | 2016-05-10 14:46:43 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-05-23 16:11:45 +0200 |
commit | cae7b7828934f5b31bfc6b506ca2b5bac8dcde05 (patch) | |
tree | 36ab8f12b6bc4211906fb6e1d8a01d18312a3364 /tests | |
parent | 77498660dbef6cb34e5ebe5bb99647714d9ffeba (diff) | |
download | dotty-cae7b7828934f5b31bfc6b506ca2b5bac8dcde05.tar.gz dotty-cae7b7828934f5b31bfc6b506ca2b5bac8dcde05.tar.bz2 dotty-cae7b7828934f5b31bfc6b506ca2b5bac8dcde05.zip |
Add Eq instances of standard types to Predef
To make tests pass, this required a looser specification of
`assumedCanEquals`, so that an abstract type T can be compared to
arbitrary values, as long as its upper bound can be compared. E.g.
T == null
T == "abc"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/equality.scala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/neg/equality.scala b/tests/neg/equality.scala index 4434aa160..680a12725 100644 --- a/tests/neg/equality.scala +++ b/tests/neg/equality.scala @@ -14,12 +14,17 @@ object equality { implicit def eqNum: Eq[Num, Num] = Eq implicit def eqOption[T, U](implicit e: Eq[T, U]): Eq[Option[T], Option[U]] = Eq + case class PString(a: String) extends Proxy { + def self = a + } + +/* implicit def eqString: Eq[String, String] = Eq implicit def eqInt: Eq[Int, Int] = Eq implicit def eqNumber: Eq[Number, Number] = Eq implicit def eqIntNumber: Eq[Int, Number] = Eq implicit def eqNumberInt: Eq[Number, Int] = Eq - +*/ def main(args: Array[String]): Unit = { Some(Other(3)) == None @@ -73,6 +78,9 @@ object equality { i == bi bi == i + val ps = PString("hello") + ps == "world" + n match { case None => // error } @@ -96,5 +104,6 @@ object equality { 1 == "abc" // error "abc" == bi // error bi == "abc" // error + "world" == ps // error } } |