summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Sabin <miles@milessabin.com>2016-05-06 12:39:13 +0100
committerMiles Sabin <miles@milessabin.com>2016-05-06 12:39:13 +0100
commit5faad77ccebb41e9674b103d499de927c0dba662 (patch)
tree04f2d34611e0f3bbe194ce9883923d85e35bf00f
parentfa65623cd8d4e60368126fc958c7185ca5706a6b (diff)
downloadscala-5faad77ccebb41e9674b103d499de927c0dba662.tar.gz
scala-5faad77ccebb41e9674b103d499de927c0dba662.tar.bz2
scala-5faad77ccebb41e9674b103d499de927c0dba662.zip
Added pos test with multiple cases; added neg tests.
-rw-r--r--test/files/neg/hkgadt.check31
-rw-r--r--test/files/neg/hkgadt.scala35
-rw-r--r--test/files/pos/hkgadt.scala25
3 files changed, 87 insertions, 4 deletions
diff --git a/test/files/neg/hkgadt.check b/test/files/neg/hkgadt.check
new file mode 100644
index 0000000000..ef302a9abf
--- /dev/null
+++ b/test/files/neg/hkgadt.check
@@ -0,0 +1,31 @@
+hkgadt.scala:7: error: type mismatch;
+ found : scala.collection.immutable.Set[Int]
+ required: F[Int]
+ case Bar() => Set(1)
+ ^
+hkgadt.scala:13: error: type mismatch;
+ found : Boolean(true)
+ required: A
+ case Bar1() => true
+ ^
+hkgadt.scala:24: error: type mismatch;
+ found : scala.collection.immutable.Set[Int]
+ required: F[Int]
+ case Bar() => Set(1)
+ ^
+hkgadt.scala:25: error: type mismatch;
+ found : List[Int]
+ required: F[Int]
+ case Baz() => List(1)
+ ^
+hkgadt.scala:32: error: type mismatch;
+ found : Boolean(true)
+ required: A
+ case Bar1() => true
+ ^
+hkgadt.scala:33: error: type mismatch;
+ found : Int(1)
+ required: A
+ case Baz1() => 1
+ ^
+6 errors found
diff --git a/test/files/neg/hkgadt.scala b/test/files/neg/hkgadt.scala
new file mode 100644
index 0000000000..0107d2bdde
--- /dev/null
+++ b/test/files/neg/hkgadt.scala
@@ -0,0 +1,35 @@
+object HKGADT {
+ sealed trait Foo[F[_]]
+ final case class Bar() extends Foo[List]
+
+ def frob[F[_]](foo: Foo[F]): F[Int] =
+ foo match {
+ case Bar() => Set(1)
+ }
+
+ sealed trait Foo1[F]
+ final case class Bar1() extends Foo1[Int]
+ def frob1[A](foo: Foo1[A]): A = foo match {
+ case Bar1() => true
+ }
+}
+
+object HKGADT2 {
+ sealed trait Foo[F[_]]
+ final case class Bar() extends Foo[List]
+ final case class Baz() extends Foo[Set]
+
+ def frob[F[_]](foo: Foo[F]): F[Int] =
+ foo match {
+ case Bar() => Set(1)
+ case Baz() => List(1)
+ }
+
+ sealed trait Foo1[F]
+ final case class Bar1() extends Foo1[Int]
+ final case class Baz1() extends Foo1[Boolean]
+ def frob1[A](foo: Foo1[A]): A = foo match {
+ case Bar1() => true
+ case Baz1() => 1
+ }
+}
diff --git a/test/files/pos/hkgadt.scala b/test/files/pos/hkgadt.scala
index 0f3739f4d4..5719c752cd 100644
--- a/test/files/pos/hkgadt.scala
+++ b/test/files/pos/hkgadt.scala
@@ -1,18 +1,35 @@
-package test
-
object HKGADT {
sealed trait Foo[F[_]]
final case class Bar() extends Foo[List]
def frob[F[_]](foo: Foo[F]): F[Int] =
foo match {
- case Bar() =>
- List(1)
+ case Bar() => List(1)
+ }
+
+ sealed trait Foo1[F]
+ final case class Bar1() extends Foo1[Int]
+ def frob1[A](foo: Foo1[A]): A = foo match {
+ case Bar1() => 1
+ }
+}
+
+object HKGADT2 {
+ sealed trait Foo[F[_]]
+ final case class Bar() extends Foo[List]
+ final case class Baz() extends Foo[Set]
+
+ def frob[F[_]](foo: Foo[F]): F[Int] =
+ foo match {
+ case Bar() => List(1)
+ case Baz() => Set(1)
}
sealed trait Foo1[F]
final case class Bar1() extends Foo1[Int]
+ final case class Baz1() extends Foo1[Boolean]
def frob1[A](foo: Foo1[A]): A = foo match {
case Bar1() => 1
+ case Baz1() => true
}
}