aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-08-17 14:34:20 +0200
committerGuillaume Martres <smarter@ubuntu.com>2016-08-17 15:37:14 -0700
commitb31d59985737d54c912c988ce26175ccaae80606 (patch)
tree7719186e433d37620ef8c92ab70613cf68e1a844 /tests
parent5f598e8094c1dba3c6cf302383088f4f00626222 (diff)
downloaddotty-b31d59985737d54c912c988ce26175ccaae80606.tar.gz
dotty-b31d59985737d54c912c988ce26175ccaae80606.tar.bz2
dotty-b31d59985737d54c912c988ce26175ccaae80606.zip
Harden copmpareHkApply for ill-typed programs
Turn assertion into test. Without this, neg/tcpoly_overloaded.scala fails.
Diffstat (limited to 'tests')
-rw-r--r--tests/neg/tcpoly_overloaded.scala25
-rw-r--r--tests/pos/tcpoly_bounds1.scala (renamed from tests/pending/pos/tcpoly_bounds1.scala)2
-rw-r--r--tests/pos/tcpoly_overloaded.scala (renamed from tests/pending/pos/tcpoly_overloaded.scala)4
3 files changed, 28 insertions, 3 deletions
diff --git a/tests/neg/tcpoly_overloaded.scala b/tests/neg/tcpoly_overloaded.scala
new file mode 100644
index 000000000..beefb6524
--- /dev/null
+++ b/tests/neg/tcpoly_overloaded.scala
@@ -0,0 +1,25 @@
+trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] {
+ def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_],
+ Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]]
+ (f: T => Result[S]): Result[S]
+ def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_],
+ Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]]
+ (f: T => Result[S], foo: String): Result[S]
+ def flatMap[S <: Bound[S]]
+ (f: T => MyType[S], foo: Int): MyType[S]
+}
+
+trait Test {
+ def moo: MList[Int]
+ class MList[T](el: T) extends Monad[T, List, Any] { // error: does not conform to upper bound // error
+ def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_],
+ Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]]
+ (f: T => Result[S]): Result[S] = sys.error("foo")
+ def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_],
+ Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]]
+ (f: T => Result[S], foo: String): Result[S] = sys.error("foo")
+ def flatMap[S]
+ (f: T => List[S], foo: Int): List[S] = sys.error("foo")
+ }
+ val l: MList[String] = moo.flatMap[String, List, Any, MList]((x: Int) => new MList("String")) // error: does not conform to upper bound // error
+}
diff --git a/tests/pending/pos/tcpoly_bounds1.scala b/tests/pos/tcpoly_bounds1.scala
index 63263cb15..9831e0b99 100644
--- a/tests/pending/pos/tcpoly_bounds1.scala
+++ b/tests/pos/tcpoly_bounds1.scala
@@ -7,7 +7,7 @@ object foo extends Foo[MyPair]
trait Monad[m[x <: Bound[x]], Bound[x], a] // TODO: variances!
-trait ListMonad[a] extends Monad[List, Any, a]
+trait ListMonad[a] extends Monad[List, [X] -> Any, a] // Dotty difference: Any is not a legal argument for hk type.
trait MyOrdered[a]
trait MySet[x <: MyOrdered[x]]
diff --git a/tests/pending/pos/tcpoly_overloaded.scala b/tests/pos/tcpoly_overloaded.scala
index 4f6334685..573eaadcb 100644
--- a/tests/pending/pos/tcpoly_overloaded.scala
+++ b/tests/pos/tcpoly_overloaded.scala
@@ -11,7 +11,7 @@ trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] {
trait Test {
def moo: MList[Int]
- class MList[T](el: T) extends Monad[T, List, Any] {
+ class MList[T](el: T) extends Monad[T, List, [X] -> Any] {
def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_],
Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]]
(f: T => Result[S]): Result[S] = sys.error("foo")
@@ -21,5 +21,5 @@ trait Test {
def flatMap[S]
(f: T => List[S], foo: Int): List[S] = sys.error("foo")
}
- val l: MList[String] = moo.flatMap[String, List, Any, MList]((x: Int) => new MList("String"))
+ val l: MList[String] = moo.flatMap[String, List, [X] -> Any, MList]((x: Int) => new MList("String"))
}