aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-02-28 18:59:08 +0100
committerMartin Odersky <odersky@gmail.com>2017-04-04 13:29:38 +0200
commit44d9ab81886a9ff0b7256fccb584c049f1c18027 (patch)
treeeff314cd55d1917ed9f1cb1d6caba551a3f04a51 /tests
parent91a26b3f42d1218015acb9b7e1bfc180e3ed779b (diff)
downloaddotty-44d9ab81886a9ff0b7256fccb584c049f1c18027.tar.gz
dotty-44d9ab81886a9ff0b7256fccb584c049f1c18027.tar.bz2
dotty-44d9ab81886a9ff0b7256fccb584c049f1c18027.zip
Support cases with type parameters that extend a non-parameterized base
Support cases with type parameters that implicitly extend a non-parameterized base without needing their own extends clause. The proposal has been updated to make clear that this is supported. Also address other reviewers comments.
Diffstat (limited to 'tests')
-rw-r--r--tests/run/enum-HList.scala22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/run/enum-HList.scala b/tests/run/enum-HList.scala
new file mode 100644
index 000000000..c019cb6cc
--- /dev/null
+++ b/tests/run/enum-HList.scala
@@ -0,0 +1,22 @@
+enum HLst {
+ case HCons[+Hd, +Tl <: HLst](hd: Hd, tl: Tl)
+ case HNil
+}
+
+object Test {
+ import HLst._
+ def length(hl: HLst): Int = hl match {
+ case HCons(_, tl) => 1 + length(tl)
+ case HNil => 0
+ }
+ def sumInts(hl: HLst): Int = hl match {
+ case HCons(x: Int, tl) => x + sumInts(tl)
+ case HCons(_, tl) => sumInts(tl)
+ case HNil => 0
+ }
+ def main(args: Array[String]) = {
+ val hl = HCons(1, HCons("A", HNil))
+ assert(length(hl) == 2, length(hl))
+ assert(sumInts(hl) == 1)
+ }
+}