summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan@lightbend.com>2016-10-18 10:41:48 -0700
committerGitHub <noreply@github.com>2016-10-18 10:41:48 -0700
commitaf41493ea423fa49e26c3e57ad5b4adc5f20237d (patch)
tree55193808f0540136908729a678338c16a4b1f936 /test/files/neg
parent9f7c26e8ccc809c48484921f87b52eb56b978dcf (diff)
parent9e2b10fc02a60a8e24c38a8f0e52b5196c47145f (diff)
downloadscala-af41493ea423fa49e26c3e57ad5b4adc5f20237d.tar.gz
scala-af41493ea423fa49e26c3e57ad5b4adc5f20237d.tar.bz2
scala-af41493ea423fa49e26c3e57ad5b4adc5f20237d.zip
Merge pull request #5343 from milessabin/topic/si-2712-backport
SI-2712 Add support for higher order unification
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/t2712-1.check13
-rw-r--r--test/files/neg/t2712-1.scala8
-rw-r--r--test/files/neg/t2712-2.check13
-rw-r--r--test/files/neg/t2712-2.flags1
-rw-r--r--test/files/neg/t2712-2.scala18
-rw-r--r--test/files/neg/t2712-3.check6
-rw-r--r--test/files/neg/t2712-3.scala18
-rw-r--r--test/files/neg/t2712.flags1
8 files changed, 78 insertions, 0 deletions
diff --git a/test/files/neg/t2712-1.check b/test/files/neg/t2712-1.check
new file mode 100644
index 0000000000..61e4b6b149
--- /dev/null
+++ b/test/files/neg/t2712-1.check
@@ -0,0 +1,13 @@
+t2712-1.scala:7: error: no type parameters for method foo: (m: M[A])Unit exist so that it can be applied to arguments (test.Two[Int,String])
+ --- because ---
+argument expression's type is not compatible with formal parameter type;
+ found : test.Two[Int,String]
+ required: ?M[?A]
+ def test(ma: Two[Int, String]) = foo(ma) // should fail with -Ypartial-unification *disabled*
+ ^
+t2712-1.scala:7: error: type mismatch;
+ found : test.Two[Int,String]
+ required: M[A]
+ def test(ma: Two[Int, String]) = foo(ma) // should fail with -Ypartial-unification *disabled*
+ ^
+two errors found
diff --git a/test/files/neg/t2712-1.scala b/test/files/neg/t2712-1.scala
new file mode 100644
index 0000000000..f7967d71b6
--- /dev/null
+++ b/test/files/neg/t2712-1.scala
@@ -0,0 +1,8 @@
+package test
+
+trait Two[A, B]
+
+object Test {
+ def foo[M[_], A](m: M[A]) = ()
+ def test(ma: Two[Int, String]) = foo(ma) // should fail with -Ypartial-unification *disabled*
+}
diff --git a/test/files/neg/t2712-2.check b/test/files/neg/t2712-2.check
new file mode 100644
index 0000000000..ea19e33e2c
--- /dev/null
+++ b/test/files/neg/t2712-2.check
@@ -0,0 +1,13 @@
+t2712-2.scala:16: error: type mismatch;
+ found : test.Foo
+ required: test.Two[test.X1,Object]
+Note: test.X2 <: Object (and test.Foo <: test.Two[test.X1,test.X2]), but trait Two is invariant in type B.
+You may wish to define B as +B instead. (SLS 4.5)
+ test1(foo): One[X3] // fails with -Ypartial-unification enabled
+ ^
+t2712-2.scala:16: error: type mismatch;
+ found : test.Two[test.X1,Object]
+ required: test.One[test.X3]
+ test1(foo): One[X3] // fails with -Ypartial-unification enabled
+ ^
+two errors found
diff --git a/test/files/neg/t2712-2.flags b/test/files/neg/t2712-2.flags
new file mode 100644
index 0000000000..41565c7e32
--- /dev/null
+++ b/test/files/neg/t2712-2.flags
@@ -0,0 +1 @@
+-Ypartial-unification
diff --git a/test/files/neg/t2712-2.scala b/test/files/neg/t2712-2.scala
new file mode 100644
index 0000000000..85ed523489
--- /dev/null
+++ b/test/files/neg/t2712-2.scala
@@ -0,0 +1,18 @@
+package test
+
+class X1
+class X2
+class X3
+
+trait One[A]
+trait Two[A, B]
+
+class Foo extends Two[X1, X2] with One[X3]
+object Test {
+ def test1[M[_], A](x: M[A]): M[A] = x
+
+ val foo = new Foo
+
+ test1(foo): One[X3] // fails with -Ypartial-unification enabled
+ test1(foo): Two[X1, X2] // fails without -Ypartial-unification
+}
diff --git a/test/files/neg/t2712-3.check b/test/files/neg/t2712-3.check
new file mode 100644
index 0000000000..a84d96bf09
--- /dev/null
+++ b/test/files/neg/t2712-3.check
@@ -0,0 +1,6 @@
+t2712-3.scala:17: error: type mismatch;
+ found : test.One[test.X3]
+ required: test.Two[test.X1,test.X2]
+ test1(foo): Two[X1, X2] // fails without -Ypartial-unification
+ ^
+one error found
diff --git a/test/files/neg/t2712-3.scala b/test/files/neg/t2712-3.scala
new file mode 100644
index 0000000000..85ed523489
--- /dev/null
+++ b/test/files/neg/t2712-3.scala
@@ -0,0 +1,18 @@
+package test
+
+class X1
+class X2
+class X3
+
+trait One[A]
+trait Two[A, B]
+
+class Foo extends Two[X1, X2] with One[X3]
+object Test {
+ def test1[M[_], A](x: M[A]): M[A] = x
+
+ val foo = new Foo
+
+ test1(foo): One[X3] // fails with -Ypartial-unification enabled
+ test1(foo): Two[X1, X2] // fails without -Ypartial-unification
+}
diff --git a/test/files/neg/t2712.flags b/test/files/neg/t2712.flags
new file mode 100644
index 0000000000..41565c7e32
--- /dev/null
+++ b/test/files/neg/t2712.flags
@@ -0,0 +1 @@
+-Ypartial-unification