diff options
author | Olivier Blanvillain <olivier.blanvillain@gmail.com> | 2016-09-09 16:56:01 +0200 |
---|---|---|
committer | Olivier Blanvillain <olivier.blanvillain@gmail.com> | 2016-09-13 15:59:39 +0200 |
commit | fe09615739dbc57ef068b4d04a2223ae0bb88eaa (patch) | |
tree | 899eb8aea1337673e9bb13c37939fce30df72d13 /tests/run/t1500b.scala | |
parent | 75f4400a738da5e436ed65d6ba8c7fa2d8f4faee (diff) | |
download | dotty-fe09615739dbc57ef068b4d04a2223ae0bb88eaa.tar.gz dotty-fe09615739dbc57ef068b4d04a2223ae0bb88eaa.tar.bz2 dotty-fe09615739dbc57ef068b4d04a2223ae0bb88eaa.zip |
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.
Diffstat (limited to 'tests/run/t1500b.scala')
-rw-r--r-- | tests/run/t1500b.scala | 21 |
1 files changed, 21 insertions, 0 deletions
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) + } +} |