From fe09615739dbc57ef068b4d04a2223ae0bb88eaa Mon Sep 17 00:00:00 2001 From: Olivier Blanvillain Date: Fri, 9 Sep 2016 16:56:01 +0200 Subject: Partially fix #1500: Implicit search breaks at a certain depth The issue fixed here was introduced by 71027f15. The added `csyms.isEmpty` condition on `case nil =>` is always true, which is clearely a bug. t1500c still fails with covariant (or contravariant) type parameters on `::`, but this seams to be a more complicated issue involving the typer. --- tests/run/t1500b.scala | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/run/t1500b.scala (limited to 'tests/run/t1500b.scala') diff --git a/tests/run/t1500b.scala b/tests/run/t1500b.scala new file mode 100644 index 000000000..8b52731a5 --- /dev/null +++ b/tests/run/t1500b.scala @@ -0,0 +1,21 @@ +sealed trait Nat +sealed trait Succ[Prev <: Nat] extends Nat +sealed trait Zero extends Nat + +case class ToInt[N <: Nat](value: Int) + +object ToInt { + implicit val caseZero: ToInt[Zero] = ToInt(0) + implicit def caseSucc[Prev <: Nat](implicit e: ToInt[Prev]): ToInt[Succ[Prev]] = ToInt(e.value + 1) +} + +object Test { + def main(args: Array[String]): Unit = { + assert(implicitly[ToInt[Zero]].value == 0) + assert(implicitly[ToInt[Succ[Zero]]].value == 1) + assert(implicitly[ToInt[Succ[Succ[Zero]]]].value == 2) + assert(implicitly[ToInt[Succ[Succ[Succ[Zero]]]]].value == 3) + assert(implicitly[ToInt[Succ[Succ[Succ[Succ[Zero]]]]]].value == 4) + assert(implicitly[ToInt[Succ[Succ[Succ[Succ[Succ[Zero]]]]]]].value == 5) + } +} -- cgit v1.2.3