aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-07-07 15:14:37 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-11 13:35:07 +0200
commitfd62c7b6dc6882f658ba2d614cb95a7141842929 (patch)
tree961a38a2a1f2090e42162490223a627dd424cc03 /tests
parenteebb4b07bf3011de56f297e7d5357cbc1ee7d623 (diff)
downloaddotty-fd62c7b6dc6882f658ba2d614cb95a7141842929.tar.gz
dotty-fd62c7b6dc6882f658ba2d614cb95a7141842929.tar.bz2
dotty-fd62c7b6dc6882f658ba2d614cb95a7141842929.zip
Disallow higher-kinded types that simulate general existential types
We cannot handle such types in general. So we now check that a hk application C[args] where some of the arguments are wildcards does not have as a supertype a hk application ([X] -> B)[args]
Diffstat (limited to 'tests')
-rw-r--r--tests/neg/existentials.scala61
-rw-r--r--tests/pos-scala2/GenTraversableFactory.scala (renamed from tests/pos/GenTraversableFactory.scala)0
-rw-r--r--tests/pos-scala2/t6014.scala (renamed from tests/pos/t6014.scala)2
3 files changed, 62 insertions, 1 deletions
diff --git a/tests/neg/existentials.scala b/tests/neg/existentials.scala
new file mode 100644
index 000000000..4798504d9
--- /dev/null
+++ b/tests/neg/existentials.scala
@@ -0,0 +1,61 @@
+object TestList {
+
+ var x: ([X] -> List[List[X]])[_] = List(List(1)) // error: unreducible
+ var y: ([X] -> List[Seq[X]])[_] = List(List(1)) // error: unreducible
+
+ x = x
+ y = y
+ y = x
+
+ val h = x.head
+ val x1: List[_] = h
+
+ var z: List[_] = x
+
+}
+object TestSet {
+
+ var x: ([Y] -> Set[Set[Y]])[_] = Set(Set("a")) // error: unreducible
+ var y: ([Y] -> Set[Iterable[Y]])[_] = Set(Set("a")) // error: unreducible
+
+ x = x
+ y = y
+
+ val h = x.head
+ val h1: Set[_] = h
+
+ // val p = x.+ // infinite loop in implicit search
+
+ var z: Set[_] = x
+
+}
+class TestX {
+
+ class C[T](x: T) {
+ def get: T = x
+ def cmp: T => Boolean = (x == _)
+ }
+
+ val x: ([Y] -> C[C[Y]])[_] = new C(new C("a")) // error: unreducible
+
+ type CC[X] = C[C[X]]
+ val y: CC[_] = ??? // error: unreducible
+
+ type D[X] <: C[X]
+
+ type DD = [X] -> D[D[X]]
+ val z: DD[_] = ??? // error: unreducible
+
+ val g = x.get
+
+ val c = x.cmp
+}
+
+object Test6014 {
+ case class CC[T](key: T)
+ type Alias[T] = Seq[CC[T]]
+
+ def f(xs: Seq[CC[_]]) = xs map { case CC(x) => CC(x) } // ok
+ def g(xs: Alias[_]) = xs map { case CC(x) => CC(x) } // error: unreducible application
+}
+
diff --git a/tests/pos/GenTraversableFactory.scala b/tests/pos-scala2/GenTraversableFactory.scala
index 2f93ab27b..2f93ab27b 100644
--- a/tests/pos/GenTraversableFactory.scala
+++ b/tests/pos-scala2/GenTraversableFactory.scala
diff --git a/tests/pos/t6014.scala b/tests/pos-scala2/t6014.scala
index 26e258a27..02535f377 100644
--- a/tests/pos/t6014.scala
+++ b/tests/pos-scala2/t6014.scala
@@ -3,7 +3,7 @@ object Test {
type Alias[T] = Seq[CC[T]]
def f(xs: Seq[CC[_]]) = xs map { case CC(x) => CC(x) } // ok
- def g(xs: Alias[_]) = xs map { case CC(x) => CC(x) } // fails
+ def g(xs: Alias[_]) = xs map { case CC(x) => CC(x) } // migration warning: unreducible application
// ./a.scala:11: error: missing parameter type for expanded function
// The argument types of an anonymous function must be fully known. (SLS 8.5)
// Expected type was: ?