diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/new/implicits.scala | 9 | ||||
-rw-r--r-- | tests/pos/implicits1.scala | 4 | ||||
-rw-r--r-- | tests/run/t8280.check | 4 | ||||
-rw-r--r-- | tests/run/t8280.scala | 12 |
4 files changed, 23 insertions, 6 deletions
diff --git a/tests/new/implicits.scala b/tests/new/implicits.scala new file mode 100644 index 000000000..1a3e0b4da --- /dev/null +++ b/tests/new/implicits.scala @@ -0,0 +1,9 @@ +object Test { + + class X(i: Int) + + implicit def int2x(i: Int): X = new X(i) + + val x: X = Byte.MinValue + +} 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) + } diff --git a/tests/run/t8280.check b/tests/run/t8280.check index ed392841c..44c51f5aa 100644 --- a/tests/run/t8280.check +++ b/tests/run/t8280.check @@ -1,8 +1,6 @@ Int Int -Int -Int -Int +Long Int Int Int diff --git a/tests/run/t8280.scala b/tests/run/t8280.scala index 0734d63b6..f433dcc32 100644 --- a/tests/run/t8280.scala +++ b/tests/run/t8280.scala @@ -20,7 +20,12 @@ object Moop1 { implicit object f1 extends (Int => String) { def apply(x: Int): String = "Int" } implicit object f2 extends (Long => String) { def apply(x: Long): String = "Long" } - println(5: String) + // println(5: String) + // Dotty deviation. The above fails for Dotty with ambiguity error. + // Both f1 and f2 are applicable conversions for Int => String. Neither is better than the other. + // Scala2 contains a hack for backwards compatibility, which we are not forced to repeat. + // See discussion under SI-8280. + } object ob2 { implicit object f1 extends (Int => String) { def apply(x: Int): String = "Int" } @@ -42,7 +47,7 @@ object Moop2 { implicit def f1(x: Int): String = "Int" implicit object f2 extends (Long => String) { def apply(x: Long): String = "Long" } - println(5: String) + println(5: String) // Dotty deviation: Dotty picks f2, because non-methods are more specific than methods } object ob2 { implicit def f1(x: Int): String = "Int" @@ -64,7 +69,8 @@ object Moop3 { implicit val f1: Int => String = _ => "Int" implicit object f2 extends (Long => String) { def apply(x: Long): String = "Long" } - println(5: String) + // println(5: String) + // Dotty deviation. This fails for Dotty with ambiguity error for similar reasons as ob1. } object ob2 { implicit val f1: Int => String = _ => "Int" |