aboutsummaryrefslogtreecommitdiff
path: root/tests/pos
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-10-14 22:45:35 +0200
committerMartin Odersky <odersky@gmail.com>2016-10-15 13:08:32 +0200
commita4ac5e066ee3072a78eec1a4125cc46ba823d41b (patch)
tree30f1aa0fca431702c1d1384175ecb3f390e532e0 /tests/pos
parent8bfaadaae141e83db7f515b042fcee26ed0e54fd (diff)
downloaddotty-a4ac5e066ee3072a78eec1a4125cc46ba823d41b.tar.gz
dotty-a4ac5e066ee3072a78eec1a4125cc46ba823d41b.tar.bz2
dotty-a4ac5e066ee3072a78eec1a4125cc46ba823d41b.zip
Fix-#1500 Include constraining type variables when interpolating
Fixes #1500. Review by @smarter.
Diffstat (limited to 'tests/pos')
-rw-r--r--tests/pos/i1500.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/pos/i1500.scala b/tests/pos/i1500.scala
new file mode 100644
index 000000000..713d06689
--- /dev/null
+++ b/tests/pos/i1500.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 HListTest {
+ 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)
+ }
+}