aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/implicits1.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-11-01 16:08:46 +0100
committerMartin Odersky <odersky@gmail.com>2015-11-01 16:08:46 +0100
commit5ed617b9ac205b831ec69b782472b1afc5752378 (patch)
treeeab7d1dd8608a633222ef53b4005364eca3b2226 /tests/pos/implicits1.scala
parent08e880231ff5facd55a80bed0391b22fe85a9f44 (diff)
downloaddotty-5ed617b9ac205b831ec69b782472b1afc5752378.tar.gz
dotty-5ed617b9ac205b831ec69b782472b1afc5752378.tar.bz2
dotty-5ed617b9ac205b831ec69b782472b1afc5752378.zip
Better handling of implicits over numeric types.
Compiling scala.math.BigDecimal and scala.math.BigInteger shows a problem. The conversion `int2bigInt` is not applicable to a Byte because `Byte -> Int` requires another implicit conversion. We fix that by using a new method relaxed_<:< for implicit compatibility checks, which always admits numeric widenings. This leads to another problem. Now the conversions implicit def byteToInt(x: Byte): Int implicit def byteToShort(x: Byte): Short are ambiguous when we try to convert from Byte to Int. We fix that by adding a "tie-break" to implicit search where if several methods match a numeric value result type and all have numeric value types as result types, we pick the numerically largest type that matches.
Diffstat (limited to 'tests/pos/implicits1.scala')
-rw-r--r--tests/pos/implicits1.scala4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/pos/implicits1.scala b/tests/pos/implicits1.scala
index d8ca76de5..eda134663 100644
--- a/tests/pos/implicits1.scala
+++ b/tests/pos/implicits1.scala
@@ -36,6 +36,8 @@ object Implicits {
val d: Int = z.foo("abc")
+ val x: X = Byte.MinValue
+
//import X.BarDeco
println(z.bar)
@@ -50,4 +52,6 @@ object Implicits {
val s: Modifier = Some("rd").getOrElse("")
+ val xx: Int = (1: Byte)
+
}