diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2007-04-06 09:39:53 +0000 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2007-04-06 09:39:53 +0000 |
commit | f96b6beefc08f56218ac68b37a4cecd757cb60ee (patch) | |
tree | 2001a44efae7ddd1699520d3855598ef13e30803 /test/files/neg | |
parent | 10a651a13c323366223160bfa1b4fe8a6e818d1d (diff) | |
download | scala-f96b6beefc08f56218ac68b37a4cecd757cb60ee.tar.gz scala-f96b6beefc08f56218ac68b37a4cecd757cb60ee.tar.bz2 scala-f96b6beefc08f56218ac68b37a4cecd757cb60ee.zip |
adding test files from tcpoly branch without hi...
adding test files from tcpoly branch without history -- much faster this way, sorry
Diffstat (limited to 'test/files/neg')
20 files changed, 217 insertions, 0 deletions
diff --git a/test/files/neg/higherkind_novalue.check b/test/files/neg/higherkind_novalue.check new file mode 100644 index 0000000000..932f7876b1 --- /dev/null +++ b/test/files/neg/higherkind_novalue.check @@ -0,0 +1,7 @@ +higherkind_novalue.scala:2: error: type m takes type parameters + val x: m // type of kind *->* doesn't classify a value, but a val/def/... can only contain/return a value + ^ +higherkind_novalue.scala:3: error: type m takes type parameters + def y: m + ^ +two errors found diff --git a/test/files/neg/higherkind_novalue.scala b/test/files/neg/higherkind_novalue.scala new file mode 100644 index 0000000000..c2e117b60e --- /dev/null +++ b/test/files/neg/higherkind_novalue.scala @@ -0,0 +1,4 @@ +abstract class HigherKind[m[s]] { + val x: m // type of kind *->* doesn't classify a value, but a val/def/... can only contain/return a value + def y: m +}
\ No newline at end of file diff --git a/test/files/neg/tcpoly_bounds.check b/test/files/neg/tcpoly_bounds.check new file mode 100644 index 0000000000..03e22f9fbc --- /dev/null +++ b/test/files/neg/tcpoly_bounds.check @@ -0,0 +1,4 @@ +tcpoly_bounds.scala:3: error: type arguments [scala.List] do not conform to class A's type parameter bounds [m<: [x]>: scala.Nothing <: scala.Option[x]] +object b extends A[List] + ^ +one error found diff --git a/test/files/neg/tcpoly_bounds.scala b/test/files/neg/tcpoly_bounds.scala new file mode 100644 index 0000000000..ae1f410fac --- /dev/null +++ b/test/files/neg/tcpoly_bounds.scala @@ -0,0 +1,3 @@ +class A[m[x] <: Option[x]] +object a extends A[Some] +object b extends A[List]
\ No newline at end of file diff --git a/test/files/neg/tcpoly_typealias.check b/test/files/neg/tcpoly_typealias.check new file mode 100644 index 0000000000..56912c49b7 --- /dev/null +++ b/test/files/neg/tcpoly_typealias.check @@ -0,0 +1,13 @@ +tcpoly_typealias.scala:37: error: The kind of type m does not conform to the expected kind of type m<: [+x]>: scala.Nothing <: scala.Any in trait A. +BInv.this.m's type parameters do not match type m's expected parameters: type x (in trait BInv) is invariant, but type x (in trait A) is declared covariant + type m[x] = FooCov[x] // error: invariant x in alias def + ^ +tcpoly_typealias.scala:41: error: The kind of type m does not conform to the expected kind of type m<: [+x]>: scala.Nothing <: scala.Any in trait A. +BCon.this.m's type parameters do not match type m's expected parameters: type x (in trait BCon) is contravariant, but type x (in trait A) is declared covariant + type m[-x] = FooCon[x] // error: contravariant x + ^ +tcpoly_typealias.scala:45: error: The kind of type m does not conform to the expected kind of type m<: [+x]>: scala.Nothing <: scala.Any in trait A. +BBound.this.m's type parameters do not match type m's expected parameters: type x (in trait BBound)'s bounds >: scala.Nothing <: scala.Predef.String are stricter than type x (in trait A)'s declared bounds >: scala.Nothing <: scala.Any + type m[+x <: String] = FooBound[x] // error: x with stricter bound + ^ +three errors found diff --git a/test/files/neg/tcpoly_typealias.scala b/test/files/neg/tcpoly_typealias.scala new file mode 100644 index 0000000000..6c7f80cc0b --- /dev/null +++ b/test/files/neg/tcpoly_typealias.scala @@ -0,0 +1,47 @@ +trait A { + type m[+x] +} + +trait A2 { + type m[+x <: String] +} + +trait A3 { + type m[x] +} + +trait FooCov[+x] +trait FooCon[-x] +trait FooBound[+x <: String] + +trait BOk1 extends A { + type m[+x] = FooCov[x] +} + +trait BOk2 extends A2 { + type m[+x <: String] = FooBound[x] +} + +trait BOk3 extends A2 { + type m[+x] = FooCov[x] // weaker bound +} + +trait BOk4 extends A3 { + type m[+x] = FooCov[x] // weaker variance +} + +// there are two aspects to check: + // does type alias signature (not considering RHS) correspond to abstract type member in super class + // does RHS correspond to the type alias sig +trait BInv extends A{ + type m[x] = FooCov[x] // error: invariant x in alias def +} + +trait BCon extends A{ + type m[-x] = FooCon[x] // error: contravariant x +} + +trait BBound extends A{ + type m[+x <: String] = FooBound[x] // error: x with stricter bound +} + diff --git a/test/files/neg/tcpoly_variance.check b/test/files/neg/tcpoly_variance.check new file mode 100644 index 0000000000..5fd104d607 --- /dev/null +++ b/test/files/neg/tcpoly_variance.check @@ -0,0 +1,5 @@ +tcpoly_variance.scala:6: error: error overriding method str in class A of type => m[java.lang.Object]; + method str has incompatible type => m[scala.Predef.String] + override def str: m[String] = error("foo") // since x in m[x] is invariant, ! m[String] <: m[Object] + ^ +one error found diff --git a/test/files/neg/tcpoly_variance.scala b/test/files/neg/tcpoly_variance.scala new file mode 100644 index 0000000000..8122938113 --- /dev/null +++ b/test/files/neg/tcpoly_variance.scala @@ -0,0 +1,7 @@ +class A[m[x]] { + def str: m[Object] = error("foo") +} + +class B[m[x]] extends A[m] { + override def str: m[String] = error("foo") // since x in m[x] is invariant, ! m[String] <: m[Object] +}
\ No newline at end of file diff --git a/test/files/neg/tcpoly_variance_enforce.check b/test/files/neg/tcpoly_variance_enforce.check new file mode 100644 index 0000000000..c66440434b --- /dev/null +++ b/test/files/neg/tcpoly_variance_enforce.check @@ -0,0 +1,45 @@ +tcpoly_variance_enforce.scala:15: error: the kinds of the type arguments (FooInvar) do not conform to the expected kinds of the type parameters (type m) in trait coll. +FooInvar's type parameters do not match type m's expected parameters: type x (in class FooInvar) is invariant, but type x is declared covariant +object fcollinv extends coll[FooInvar] // error + ^ +tcpoly_variance_enforce.scala:16: error: the kinds of the type arguments (FooContra) do not conform to the expected kinds of the type parameters (type m) in trait coll. +FooContra's type parameters do not match type m's expected parameters: type x (in class FooContra) is contravariant, but type x is declared covariant +object fcollcon extends coll[FooContra] // error + ^ +tcpoly_variance_enforce.scala:17: error: the kinds of the type arguments (FooString) do not conform to the expected kinds of the type parameters (type m) in trait coll. +FooString's type parameters do not match type m's expected parameters: type x (in class FooString)'s bounds >: scala.Nothing <: scala.Predef.String are stricter than type x's declared bounds >: scala.Nothing <: scala.Any +object fcollwb extends coll[FooString] // error + ^ +tcpoly_variance_enforce.scala:19: error: the kinds of the type arguments (FooCov) do not conform to the expected kinds of the type parameters (type m) in trait coll2. +FooCov's type parameters do not match type m's expected parameters: type x (in class FooCov) is covariant, but type x is declared contravariant +object fcoll2ok extends coll2[FooCov] // error + ^ +tcpoly_variance_enforce.scala:20: error: the kinds of the type arguments (FooInvar) do not conform to the expected kinds of the type parameters (type m) in trait coll2. +FooInvar's type parameters do not match type m's expected parameters: type x (in class FooInvar) is invariant, but type x is declared contravariant +object fcoll2inv extends coll2[FooInvar] // error + ^ +tcpoly_variance_enforce.scala:22: error: the kinds of the type arguments (FooString) do not conform to the expected kinds of the type parameters (type m) in trait coll2. +FooString's type parameters do not match type m's expected parameters: type x (in class FooString) is covariant, but type x is declared contravarianttype x (in class FooString)'s bounds >: scala.Nothing <: scala.Predef.String are stricter than type x's declared bounds >: scala.Nothing <: scala.Any +object fcoll2wb extends coll2[FooString] // error + ^ +tcpoly_variance_enforce.scala:27: error: the kinds of the type arguments (FooString) do not conform to the expected kinds of the type parameters (type m) in trait coll3. +FooString's type parameters do not match type m's expected parameters: type x (in class FooString)'s bounds >: scala.Nothing <: scala.Predef.String are stricter than type x's declared bounds >: scala.Nothing <: scala.Any +object fcoll3wb extends coll3[FooString] // error + ^ +tcpoly_variance_enforce.scala:30: error: the kinds of the type arguments (FooString,scala.Int) do not conform to the expected kinds of the type parameters (type m,type y) in trait coll4. +FooString's type parameters do not match type m's expected parameters: type x (in class FooString)'s bounds >: scala.Nothing <: scala.Predef.String are stricter than type x's declared bounds >: scala.Nothing <: y +object fcoll4_1 extends coll4[FooString, Int] // error + ^ +tcpoly_variance_enforce.scala:31: error: the kinds of the type arguments (FooString,scala.Any) do not conform to the expected kinds of the type parameters (type m,type y) in trait coll4. +FooString's type parameters do not match type m's expected parameters: type x (in class FooString)'s bounds >: scala.Nothing <: scala.Predef.String are stricter than type x's declared bounds >: scala.Nothing <: y +object fcoll4_2 extends coll4[FooString, Any] // error + ^ +tcpoly_variance_enforce.scala:37: error: the kinds of the type arguments (FooInvar) do not conform to the expected kinds of the type parameters (type m) in trait coll. +FooInvar's type parameters do not match type m's expected parameters: type x (in class FooInvar) is invariant, but type x is declared covariant + def x: coll[FooInvar] = error("foo") // error + ^ +tcpoly_variance_enforce.scala:38: error: the kinds of the type arguments (FooContra) do not conform to the expected kinds of the type parameters (type m) in trait coll. +FooContra's type parameters do not match type m's expected parameters: type x (in class FooContra) is contravariant, but type x is declared covariant + def y: coll[FooContra] = error("foo") // error + ^ +11 errors found diff --git a/test/files/neg/tcpoly_variance_enforce.scala b/test/files/neg/tcpoly_variance_enforce.scala new file mode 100644 index 0000000000..e2fea37fff --- /dev/null +++ b/test/files/neg/tcpoly_variance_enforce.scala @@ -0,0 +1,42 @@ +trait coll[m[+x]] + +trait coll2[m[-x]] + +trait coll3[m[x]] + +trait coll4[m[x <: y], y] + +class FooInvar[x] +class FooContra[-x] +class FooCov[+x] +class FooString[+x <: String] + +object fcollok extends coll[FooCov] +object fcollinv extends coll[FooInvar] // error +object fcollcon extends coll[FooContra] // error +object fcollwb extends coll[FooString] // error + +object fcoll2ok extends coll2[FooCov] // error +object fcoll2inv extends coll2[FooInvar] // error +object fcoll2con extends coll2[FooContra] +object fcoll2wb extends coll2[FooString] // error + +object fcoll3ok extends coll3[FooCov] +object fcoll3inv extends coll3[FooInvar] +object fcoll3con extends coll3[FooContra] +object fcoll3wb extends coll3[FooString] // error + +object fcoll4ok extends coll4[FooString, String] +object fcoll4_1 extends coll4[FooString, Int] // error +object fcoll4_2 extends coll4[FooString, Any] // error + + +object test { + var ok: coll[FooCov] = _ + + def x: coll[FooInvar] = error("foo") // error + def y: coll[FooContra] = error("foo") // error +} + + +// TODO: need test for rank N with N >: 2
\ No newline at end of file diff --git a/test/files/neg/wellkinded_app.check b/test/files/neg/wellkinded_app.check new file mode 100644 index 0000000000..d57a0e4b56 --- /dev/null +++ b/test/files/neg/wellkinded_app.check @@ -0,0 +1,4 @@ +wellkinded_app.scala:3: error: x does not take type parameters + type t = x[x] + ^ +one error found diff --git a/test/files/neg/wellkinded_app.scala b/test/files/neg/wellkinded_app.scala new file mode 100644 index 0000000000..7fa3f95a98 --- /dev/null +++ b/test/files/neg/wellkinded_app.scala @@ -0,0 +1,4 @@ +// test well-kindedness checks +class WellKinded[x] { + type t = x[x] +} diff --git a/test/files/neg/wellkinded_app2.check b/test/files/neg/wellkinded_app2.check new file mode 100644 index 0000000000..20a177ea59 --- /dev/null +++ b/test/files/neg/wellkinded_app2.check @@ -0,0 +1,4 @@ +wellkinded_app2.scala:3: error: s does not take type parameters + val foo: s[Int] + ^ +one error found diff --git a/test/files/neg/wellkinded_app2.scala b/test/files/neg/wellkinded_app2.scala new file mode 100644 index 0000000000..5b73611964 --- /dev/null +++ b/test/files/neg/wellkinded_app2.scala @@ -0,0 +1,4 @@ +// test well-kindedness checks +class WellKinded[s <: Throwable] { + val foo: s[Int] +}
\ No newline at end of file diff --git a/test/files/neg/wellkinded_bounds.check b/test/files/neg/wellkinded_bounds.check new file mode 100644 index 0000000000..9099934c68 --- /dev/null +++ b/test/files/neg/wellkinded_bounds.check @@ -0,0 +1,4 @@ +wellkinded_bounds.scala:2: error: class List takes type parameters +class WellKindedWrongSyntax[s <: List] { // must be s[x] <: List[x] + ^ +one error found diff --git a/test/files/neg/wellkinded_bounds.scala b/test/files/neg/wellkinded_bounds.scala new file mode 100644 index 0000000000..7b80ce1cf7 --- /dev/null +++ b/test/files/neg/wellkinded_bounds.scala @@ -0,0 +1,3 @@ +// test well-kindedness checks -- syntax error +class WellKindedWrongSyntax[s <: List] { // must be s[x] <: List[x] +}
\ No newline at end of file diff --git a/test/files/neg/wellkinded_wrongarity.check b/test/files/neg/wellkinded_wrongarity.check new file mode 100644 index 0000000000..548b5e40bb --- /dev/null +++ b/test/files/neg/wellkinded_wrongarity.check @@ -0,0 +1,4 @@ +wellkinded_wrongarity.scala:5: error: type Pair takes two type parameters, expected: one +object mp extends Monad[Pair] + ^ +one error found diff --git a/test/files/neg/wellkinded_wrongarity.scala b/test/files/neg/wellkinded_wrongarity.scala new file mode 100644 index 0000000000..39f8b7a2c3 --- /dev/null +++ b/test/files/neg/wellkinded_wrongarity.scala @@ -0,0 +1,5 @@ +// test well-kindedness checks -- arity error + +class Monad[m[x]] + +object mp extends Monad[Pair]
\ No newline at end of file diff --git a/test/files/neg/wellkinded_wrongarity2.check b/test/files/neg/wellkinded_wrongarity2.check new file mode 100644 index 0000000000..353d2368a1 --- /dev/null +++ b/test/files/neg/wellkinded_wrongarity2.check @@ -0,0 +1,4 @@ +wellkinded_wrongarity2.scala:4: error: type String takes no type parameters, expected: one +object ms extends Monad[String] + ^ +one error found diff --git a/test/files/neg/wellkinded_wrongarity2.scala b/test/files/neg/wellkinded_wrongarity2.scala new file mode 100644 index 0000000000..ee9d771aaa --- /dev/null +++ b/test/files/neg/wellkinded_wrongarity2.scala @@ -0,0 +1,4 @@ +// test well-kindedness checks +class Monad[m[x]] + +object ms extends Monad[String]
\ No newline at end of file |