aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-11-01 16:42:00 +0100
committerMartin Odersky <odersky@gmail.com>2015-11-01 16:42:00 +0100
commitf48ea79df03fde590f0ba22dcc52f2c82227b9e9 (patch)
tree6a3e0f1aa2b3a883532333ca92d706232be0e5c1
parent5ed617b9ac205b831ec69b782472b1afc5752378 (diff)
downloaddotty-f48ea79df03fde590f0ba22dcc52f2c82227b9e9.tar.gz
dotty-f48ea79df03fde590f0ba22dcc52f2c82227b9e9.tar.bz2
dotty-f48ea79df03fde590f0ba22dcc52f2c82227b9e9.zip
Disable failing test
Dotty delivers an ambiguity error. The comment in the test argues why this is OK.
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala10
-rw-r--r--tests/run/t8280.scala8
2 files changed, 11 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index 7dbf6d17c..54ecb2405 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -531,11 +531,11 @@ trait Implicits { self: Typer =>
}
/** If the (result types of) the expected type, and both alternatives
- * are all numeric value types, return the alternative which is
- * the smaller numeric subtype, if it exists. (This alternative is then
- * discarded).
+ * are all numeric value types, return the alternative which has
+ * the smaller numeric subtype as result type, if it exists.
+ * (This alternative is then discarded).
*/
- def tieBreak(alt1: SearchSuccess, alt2: SearchSuccess): SearchResult = {
+ def numericValueTieBreak(alt1: SearchSuccess, alt2: SearchSuccess): SearchResult = {
def isNumeric(tp: Type) = tp.typeSymbol.isNumericValueClass
def isProperSubType(tp1: Type, tp2: Type) =
tp1.isValueSubType(tp2) && !tp2.isValueSubType(tp1)
@@ -558,7 +558,7 @@ trait Implicits { self: Typer =>
println(i"ambiguous refs: ${hits map (_.ref) map (_.show) mkString ", "}")
isAsGood(best.ref, alt.ref, explain = true)(ctx.fresh.withExploreTyperState)
*/
- tieBreak(best, alt) match {
+ numericValueTieBreak(best, alt) match {
case eliminated: SearchSuccess => condense(hits.filter(_ ne eliminated))
case _ => new AmbiguousImplicits(best.ref, alt.ref, pt, argument)
}
diff --git a/tests/run/t8280.scala b/tests/run/t8280.scala
index 0734d63b6..1c9d5cbaa 100644
--- a/tests/run/t8280.scala
+++ b/tests/run/t8280.scala
@@ -20,7 +20,11 @@ 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" }
@@ -64,7 +68,7 @@ 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.
}
object ob2 {
implicit val f1: Int => String = _ => "Int"