aboutsummaryrefslogtreecommitdiff
path: root/tests/run
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-09-14 09:22:42 +0200
committerGitHub <noreply@github.com>2016-09-14 09:22:42 +0200
commit7cff6a88cb72dee95313e1236e5f925440a5be57 (patch)
tree899eb8aea1337673e9bb13c37939fce30df72d13 /tests/run
parent75f4400a738da5e436ed65d6ba8c7fa2d8f4faee (diff)
parentfe09615739dbc57ef068b4d04a2223ae0bb88eaa (diff)
downloaddotty-7cff6a88cb72dee95313e1236e5f925440a5be57.tar.gz
dotty-7cff6a88cb72dee95313e1236e5f925440a5be57.tar.bz2
dotty-7cff6a88cb72dee95313e1236e5f925440a5be57.zip
Merge pull request #1504 from OlivierBlanvillain/fix-1500
Partially fix #1500: Implicit search breaks at a certain depth
Diffstat (limited to 'tests/run')
-rw-r--r--tests/run/t1500b.scala21
-rw-r--r--tests/run/t1500c.scala19
2 files changed, 40 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)
+ }
+}
diff --git a/tests/run/t1500c.scala b/tests/run/t1500c.scala
new file mode 100644
index 000000000..5c33b7a2f
--- /dev/null
+++ b/tests/run/t1500c.scala
@@ -0,0 +1,19 @@
+sealed trait HList
+sealed trait HNil extends HList
+sealed trait ::[H, T <: HList] extends HList
+
+case class Size[L <: HList](value: Int)
+
+object Size {
+ implicit val caseHNil: Size[HNil] = Size(0)
+ implicit def caseHCons[H, T <: HList](implicit e: Size[T]): Size[H :: T] = Size(e.value + 1)
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ assert(implicitly[Size[HNil]].value == 0)
+ assert(implicitly[Size[Int :: HNil]].value == 1)
+ assert(implicitly[Size[Int :: Int :: HNil]].value == 2)
+ assert(implicitly[Size[Int :: Int :: Int :: HNil]].value == 3)
+ }
+}