diff options
author | Martin Odersky <odersky@gmail.com> | 2016-07-12 18:12:27 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-12 18:14:04 +0200 |
commit | c7f3b45abf221c432b3fbd7462741b00a9e10142 (patch) | |
tree | 32171eb1c314e64f155fbd05d9ef01e43cac4f53 /tests | |
parent | 84a1a7ae7b1e4931fe04a5a21a04bb858e8acebb (diff) | |
download | dotty-c7f3b45abf221c432b3fbd7462741b00a9e10142.tar.gz dotty-c7f3b45abf221c432b3fbd7462741b00a9e10142.tar.bz2 dotty-c7f3b45abf221c432b3fbd7462741b00a9e10142.zip |
Drop restriction to 2nd order hk types
Allow hk type parameters to be higher kinded themselves.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/disabled/not-representable/pos/t2066.scala | 6 | ||||
-rw-r--r-- | tests/neg/t2994.scala | 6 | ||||
-rw-r--r-- | tests/pos/t2066.scala | 25 | ||||
-rw-r--r-- | tests/pos/t2712-3.scala | 24 |
4 files changed, 55 insertions, 6 deletions
diff --git a/tests/disabled/not-representable/pos/t2066.scala b/tests/disabled/not-representable/pos/t2066.scala index 30cb99d45..d175769fa 100644 --- a/tests/disabled/not-representable/pos/t2066.scala +++ b/tests/disabled/not-representable/pos/t2066.scala @@ -3,7 +3,7 @@ trait A1 { } trait B1 extends A1 { - override def f[T[_]] = () + override def f[T[+_]] = () } @@ -12,12 +12,12 @@ trait A2 { } trait B2 extends A2 { - override def f[T[_]] = () + override def f[T[-_]] = () } trait A3 { - def f[T[X[_]]] = () + def f[T[X[+_]]] = () } trait B3 extends A3 { diff --git a/tests/neg/t2994.scala b/tests/neg/t2994.scala index 23a3b6a8b..6964a080e 100644 --- a/tests/neg/t2994.scala +++ b/tests/neg/t2994.scala @@ -7,7 +7,7 @@ object Naturals { type a[s[_ <: NAT] <: NAT, z <: NAT] = z } final class SUCC[n <: NAT] extends NAT { - type a[s[_ <: NAT] <: NAT, z <: NAT] = s[n#a[s, z]] // old-error: not a legal path + type a[s[_ <: NAT] <: NAT, z <: NAT] = s[n#a[s, z]] // error: not a legal path } type _0 = ZERO type _1 = SUCC[_0] @@ -20,8 +20,8 @@ object Naturals { // crashes scala-2.8.0 beta1 trait MUL[n <: NAT, m <: NAT] extends NAT { - trait curry[n[_[_], _], s[_]] { type f[z <: NAT] = n[s, z] } // can't do double param lists: // error: `]' expected but `[` found. // error: wrong number of type arguments - type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z] // old-error: not a legal path // old-error: not a legal path + trait curry[n[_[_], _], s[_]] { type f[z <: NAT] = n[s, z] } + type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z] // error: not a legal path // error: not a legal path } } diff --git a/tests/pos/t2066.scala b/tests/pos/t2066.scala new file mode 100644 index 000000000..d175769fa --- /dev/null +++ b/tests/pos/t2066.scala @@ -0,0 +1,25 @@ +trait A1 { + def f[T[+_]] = () +} + +trait B1 extends A1 { + override def f[T[+_]] = () +} + + +trait A2 { + def f[T[-_]] = () +} + +trait B2 extends A2 { + override def f[T[-_]] = () +} + + +trait A3 { + def f[T[X[+_]]] = () +} + +trait B3 extends A3 { + override def f[T[X[+_]]] = () +} diff --git a/tests/pos/t2712-3.scala b/tests/pos/t2712-3.scala new file mode 100644 index 000000000..dd599f40f --- /dev/null +++ b/tests/pos/t2712-3.scala @@ -0,0 +1,24 @@ +package test + +object Test1 { + class Foo[T, F[_]] + def meh[M[_[_]], F[_]](x: M[F]): M[F] = x + meh(new Foo[Int, List]) // solves ?M = [X[_]]Foo[Int, X[_]] ?A = List ... +} + +object Test2 { + trait TC[T] + class Foo[F[_], G[_]] + def meh[GG[_[_]]](g: GG[TC]) = ??? + meh(new Foo[TC, TC]) // solves ?G = [X[_]]Foo[TC, X] +} + +object Test3 { + trait TC[F[_]] + trait TC2[F[_]] + class Foo[F[_[_]], G[_[_]]] + new Foo[TC, TC2] + + def meh[G[_[_[_]]]](g: G[TC2]) = ??? + meh(new Foo[TC, TC2]) // solves ?G = [X[_[_]]]Foo[TC, X] +} |