summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-05-30 16:55:39 -0700
committerPaul Phillips <paulp@improving.org>2013-05-31 04:21:43 -0700
commit14534c693d2eb6acafaf8244c14b5643388fbd67 (patch)
tree20b5bb989a4629bc794e1c9fae591dd5d98ede10 /test
parentcfef577e478161bd4d1e24626e0909c80c04e1b9 (diff)
downloadscala-14534c693d2eb6acafaf8244c14b5643388fbd67.tar.gz
scala-14534c693d2eb6acafaf8244c14b5643388fbd67.tar.bz2
scala-14534c693d2eb6acafaf8244c14b5643388fbd67.zip
SI-7517 type constructors too eagerly normalized.
I think 403eadd0f1 was largely a symptomatic remedy (not that we shouldn't harden against such outcomes) and that this commit gets closer to the root causes. The unanticipated change to test/files/run/t6113.check is like a cry of support from the jury box. -Foo[[X](Int, X)] +Foo[AnyRef{type l[X] = (Int, X)}#l] We should continue to look at calls to normalize with grave suspicion.
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t2994a.check7
-rw-r--r--test/files/neg/t2994a.scala27
-rw-r--r--test/files/pos/t2994a.scala8
-rw-r--r--test/files/pos/t2994c.scala8
-rw-r--r--test/files/pos/t7517.scala22
-rw-r--r--test/files/run/t6113.check2
-rw-r--r--test/pending/neg/t2994b.scala8
-rw-r--r--test/pending/pos/lubbing-aliases.scala40
8 files changed, 116 insertions, 6 deletions
diff --git a/test/files/neg/t2994a.check b/test/files/neg/t2994a.check
new file mode 100644
index 0000000000..24538a50c3
--- /dev/null
+++ b/test/files/neg/t2994a.check
@@ -0,0 +1,7 @@
+t2994a.scala:24: error: kinds of the type arguments (m#a,s) do not conform to the expected kinds of the type parameters (type n,type s) in trait curry.
+m#a's type parameters do not match type n's expected parameters:
+type _'s bounds <: Naturals.NAT are stricter than type _'s declared bounds >: Nothing <: Any, type z's bounds <: Naturals.NAT are stricter than type _'s declared bounds >: Nothing <: Any, s's type parameters do not match type s's expected parameters:
+type _'s bounds <: Naturals.NAT are stricter than type _ (in trait curry)'s declared bounds >: Nothing <: Any
+ type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z]
+ ^
+one error found
diff --git a/test/files/neg/t2994a.scala b/test/files/neg/t2994a.scala
new file mode 100644
index 0000000000..f2d57c34ca
--- /dev/null
+++ b/test/files/neg/t2994a.scala
@@ -0,0 +1,27 @@
+object Naturals {
+ trait NAT {
+ type a[s[_ <: NAT] <: NAT, z <: NAT] <: NAT
+ type v = a[SUCC, ZERO]
+ }
+ final class ZERO extends NAT {
+ 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]]
+ }
+ type _0 = ZERO
+ type _1 = SUCC[_0]
+ type _2 = SUCC[_1]
+ type _3 = SUCC[_2]
+ type _4 = SUCC[_3]
+ type _5 = SUCC[_4]
+ type _6 = SUCC[_5]
+
+
+ // 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] }
+ type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z]
+ }
+
+} \ No newline at end of file
diff --git a/test/files/pos/t2994a.scala b/test/files/pos/t2994a.scala
index f2d57c34ca..15456991d0 100644
--- a/test/files/pos/t2994a.scala
+++ b/test/files/pos/t2994a.scala
@@ -17,11 +17,9 @@ object Naturals {
type _5 = SUCC[_4]
type _6 = SUCC[_5]
-
- // crashes scala-2.8.0 beta1
+ // 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] }
+ trait curry[ n[ m[x1 <: NAT], x2 <: NAT], s[x3 <: NAT] ] { type f[z <: NAT] = n[s, z] }
type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z]
}
-
-} \ No newline at end of file
+}
diff --git a/test/files/pos/t2994c.scala b/test/files/pos/t2994c.scala
new file mode 100644
index 0000000000..1ad3655c89
--- /dev/null
+++ b/test/files/pos/t2994c.scala
@@ -0,0 +1,8 @@
+object Test {
+ trait Bar[X[_]]
+ trait Qux[S[_] <: Bar[S], T]
+ trait Baz[S[_] <: Bar[S]] {
+ type Apply[T] = Qux[S,T]
+ }
+ trait Foo[/**/V[_] <: Bar[V]/**/] extends Bar[Baz[V]#Apply]
+}
diff --git a/test/files/pos/t7517.scala b/test/files/pos/t7517.scala
new file mode 100644
index 0000000000..29bd0936ce
--- /dev/null
+++ b/test/files/pos/t7517.scala
@@ -0,0 +1,22 @@
+trait Box[ K[A[x]] ]
+
+object Box {
+ // type constructor composition
+ sealed trait ∙[A[_], B[_]] { type l[T] = A[B[T]] }
+
+ // composes type constructors inside K
+ type SplitBox[K[A[x]], B[x]] = Box[ ({ type l[A[x]] = K[ (A ∙ B)#l] })#l ]
+
+ def split[ K[A[x]], B[x] ](base: Box[K]): SplitBox[K,B] = ???
+
+ class Composed[B[_], K[A[x]] ] {
+ val box: Box[K] = ???
+
+ type Split[ A[x] ] = K[ (A ∙ B)#l ]
+ val a: Box[Split] = Box.split(box)
+
+ //Either of these work:
+ //val a: Box[Split] = Box.split[K,B](box)
+ //val a: Box[ ({ type l[A[x]] = K[ (A ∙ B)#l ] })#l ] = Box.split(box)
+ }
+}
diff --git a/test/files/run/t6113.check b/test/files/run/t6113.check
index 65fb3cd090..56c11d1fab 100644
--- a/test/files/run/t6113.check
+++ b/test/files/run/t6113.check
@@ -1 +1 @@
-Foo[[X](Int, X)]
+Foo[AnyRef{type l[X] = (Int, X)}#l]
diff --git a/test/pending/neg/t2994b.scala b/test/pending/neg/t2994b.scala
new file mode 100644
index 0000000000..20be85eb58
--- /dev/null
+++ b/test/pending/neg/t2994b.scala
@@ -0,0 +1,8 @@
+trait curry[s[_]] { type f = Double }
+
+// a1 and a2 fail to compile, but all three should fail.
+class A {
+ type a1[s[_ <: Int]] = curry[s]
+ type a2[s[_ <: Int]] = curry[s]#f
+ type a3[s[_ <: Int]] = Set[curry[s]#f]
+}
diff --git a/test/pending/pos/lubbing-aliases.scala b/test/pending/pos/lubbing-aliases.scala
new file mode 100644
index 0000000000..9c71a4ec91
--- /dev/null
+++ b/test/pending/pos/lubbing-aliases.scala
@@ -0,0 +1,40 @@
+trait outer[cc[x], t] {
+ type M[x]
+ type V
+}
+
+trait Coll[+A]
+trait List[+A] extends Coll[A]
+trait Set[A] extends Coll[A]
+trait Stream[+A] extends Coll[A]
+trait Vector[A] extends Coll[A]
+
+trait Foo[A] {
+ type M1[CC[x]] = outer[CC, A]#V
+ type M2[CC[x]] = M1[CC]
+ type M3[CC[x]] = outer[CC, A]#M[A]
+ type M4[CC[x]] = M3[CC]
+
+ def f1: M1[List]
+ def f2: M2[Set]
+ def f3: M3[Stream]
+ def f4: M4[Vector]
+
+ def g12 = List(f1, f2).head
+ def g13 = List(f1, f3).head
+ def g14 = List(f1, f4).head
+ def g23 = List(f2, f3).head
+ def g24 = List(f2, f4).head
+ def g34 = List(f3, f4).head
+}
+
+trait Bar extends Foo[Int] {
+ class Bippy {
+ def g12 = List(f1, f2).head
+ def g13 = List(f1, f3).head
+ def g14 = List(f1, f4).head
+ def g23 = List(f2, f3).head
+ def g24 = List(f2, f4).head
+ def g34 = List(f3, f4).head
+ }
+}