diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/tcpoly_variance_enforce.check | 22 | ||||
-rw-r--r-- | test/files/neg/variances.check | 2 | ||||
-rw-r--r-- | test/files/neg/variances.scala | 12 |
3 files changed, 24 insertions, 12 deletions
diff --git a/test/files/neg/tcpoly_variance_enforce.check b/test/files/neg/tcpoly_variance_enforce.check index c13a09221f..508ed90fbb 100644 --- a/test/files/neg/tcpoly_variance_enforce.check +++ b/test/files/neg/tcpoly_variance_enforce.check @@ -1,44 +1,44 @@ -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. +tcpoly_variance_enforce.scala:15: error: 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. +tcpoly_variance_enforce.scala:16: error: 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. +tcpoly_variance_enforce.scala:17: error: 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 >: Nothing <: String are stricter than type x's declared bounds >: Nothing <: 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. +tcpoly_variance_enforce.scala:19: error: 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. +tcpoly_variance_enforce.scala:20: error: 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. +tcpoly_variance_enforce.scala:22: error: 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 >: Nothing <: String are stricter than type x's declared bounds >: Nothing <: 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. +tcpoly_variance_enforce.scala:27: error: 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 >: Nothing <: String are stricter than type x's declared bounds >: Nothing <: Any object fcoll3wb extends coll3[FooString] // error ^ -tcpoly_variance_enforce.scala:30: error: the kinds of the type arguments (FooString,Int) do not conform to the expected kinds of the type parameters (type m,type y) in trait coll4. +tcpoly_variance_enforce.scala:30: error: kinds of the type arguments (FooString,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 >: Nothing <: String are stricter than type x's declared bounds >: Nothing <: y object fcoll4_1 extends coll4[FooString, Int] // error ^ -tcpoly_variance_enforce.scala:31: error: the kinds of the type arguments (FooString,Any) do not conform to the expected kinds of the type parameters (type m,type y) in trait coll4. +tcpoly_variance_enforce.scala:31: error: kinds of the type arguments (FooString,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 >: Nothing <: String are stricter than type x's declared bounds >: 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. +tcpoly_variance_enforce.scala:37: error: 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. +tcpoly_variance_enforce.scala:38: error: 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 ^ diff --git a/test/files/neg/variances.check b/test/files/neg/variances.check index d809d0f598..5c8ddd5159 100644 --- a/test/files/neg/variances.check +++ b/test/files/neg/variances.check @@ -4,7 +4,7 @@ variances.scala:4: error: covariant type A occurs in contravariant position in t variances.scala:14: error: covariant type A occurs in contravariant position in type A of value a private[this] def setA(a : A) = this.a = a ^ -variances.scala:16: error: covariant type A occurs in invariant position in type test.C[A] with ScalaObject{def this(): object Foo.this.Baz} of object Baz +variances.scala:16: error: covariant type A occurs in invariant position in supertype test.C[A] with ScalaObject of object Baz object Baz extends C[A] ^ three errors found diff --git a/test/files/neg/variances.scala b/test/files/neg/variances.scala index 393a3e0b7d..67783bc4aa 100644 --- a/test/files/neg/variances.scala +++ b/test/files/neg/variances.scala @@ -58,4 +58,16 @@ object Covariant { val x : java.lang.Character = test.a.getA Console.println("XXX " + x) } + + abstract class T[+A] { + val x: T[A] { + val m: A => A + } + } + object ST extends T[String] { + val x: T[String] { val m: String => String } = ST + val m: String => String = (_.substring(1)) + } + val t: T[Any] = ST + t.x.m(new Object) } |