summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-01-10 22:47:33 -0800
committerPaul Phillips <paulp@improving.org>2013-01-10 22:47:33 -0800
commitecea3fc58338f8d4d4bab0f56e2101dbf2a9c0ed (patch)
treee1d9ec4cb71546474ed0064dd7a6cfa9268d5b05 /test
parent5abadf0aebee68c9ba6a168355d5817f8a99d7e9 (diff)
parent03caf40523cc768c87080e141993ccfe5df7f57f (diff)
downloadscala-ecea3fc58338f8d4d4bab0f56e2101dbf2a9c0ed.tar.gz
scala-ecea3fc58338f8d4d4bab0f56e2101dbf2a9c0ed.tar.bz2
scala-ecea3fc58338f8d4d4bab0f56e2101dbf2a9c0ed.zip
Merge pull request #1873 from paulp/pr/variance-bonanza
a painstaking examination of Variance
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t5378.check31
-rw-r--r--test/files/neg/t5378.scala54
-rw-r--r--test/files/neg/t6566a.check4
-rw-r--r--test/files/neg/t6566a.scala17
-rw-r--r--test/files/neg/t6566b.check4
-rw-r--r--test/files/neg/t6566b.scala19
-rw-r--r--test/files/neg/variances-refinement.check22
-rw-r--r--test/files/neg/variances-refinement.scala40
-rw-r--r--test/files/neg/variances.check5
-rw-r--r--test/files/neg/variances2.check229
-rw-r--r--test/files/neg/variances2.scala303
-rw-r--r--test/files/pos/variances-flip.scala7
-rw-r--r--test/files/pos/variances-local.scala7
-rw-r--r--test/pending/neg/t5378.scala19
14 files changed, 741 insertions, 20 deletions
diff --git a/test/files/neg/t5378.check b/test/files/neg/t5378.check
new file mode 100644
index 0000000000..c1460083f6
--- /dev/null
+++ b/test/files/neg/t5378.check
@@ -0,0 +1,31 @@
+t5378.scala:7: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement
+ def contains = new { def apply[T1 <: T](value: T1) = ??? }
+ ^
+t5378.scala:8: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement
+ def contains1 = new { def apply[T1 <: A1](value: T1) = ??? }
+ ^
+t5378.scala:9: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement
+ def contains2 = new { def apply[T1 <: A2](value: T1) = ??? }
+ ^
+t5378.scala:15: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement
+ new Bippy { def apply[T1 <: T](value: T1) = ??? }
+ ^
+t5378.scala:16: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement
+ new Bippy { def apply[T1 <: B1](value: T1) = ??? }
+ ^
+t5378.scala:17: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement
+ new Bippy { def apply[T1 <: B2](value: T1) = ??? }
+ ^
+t5378.scala:21: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement
+ def apply1[T1 <: B3](value: T1) = ???
+ ^
+t5378.scala:23: error: Parameter type in structural refinement may not refer to an abstract type defined outside that refinement
+ def apply3(value: B3) = ???
+ ^
+t5378.scala:28: error: Parameter type in structural refinement may not refer to an abstract type defined outside that refinement
+ def apply1(s: String)(x: Int)(value: T) = ???
+ ^
+t5378.scala:29: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement
+ def apply2[T1 <: T](s: String)(x: Int)(value: T1) = ???
+ ^
+10 errors found
diff --git a/test/files/neg/t5378.scala b/test/files/neg/t5378.scala
new file mode 100644
index 0000000000..fa6afa02be
--- /dev/null
+++ b/test/files/neg/t5378.scala
@@ -0,0 +1,54 @@
+import scala.language.reflectiveCalls
+
+class Coll[+T] {
+ type A1 <: T
+ type A2 <: A1
+
+ def contains = new { def apply[T1 <: T](value: T1) = ??? }
+ def contains1 = new { def apply[T1 <: A1](value: T1) = ??? }
+ def contains2 = new { def apply[T1 <: A2](value: T1) = ??? }
+ def contains3 = {
+ trait Bippy {
+ type B1 <: T
+ type B2 <: B1
+ }
+ new Bippy { def apply[T1 <: T](value: T1) = ??? }
+ new Bippy { def apply[T1 <: B1](value: T1) = ??? }
+ new Bippy { def apply[T1 <: B2](value: T1) = ??? }
+ new Bippy {
+ type B3 = B2
+ type B4 = List[B2]
+ def apply1[T1 <: B3](value: T1) = ???
+ def apply2[T1 <: B4](value: T1) = ???
+ def apply3(value: B3) = ???
+ def apply4(value: B4) = value.head
+ }
+ }
+ def contains4 = new {
+ def apply1(s: String)(x: Int)(value: T) = ???
+ def apply2[T1 <: T](s: String)(x: Int)(value: T1) = ???
+ }
+ def containsOk = {
+ trait Bippy {
+ type B1 <: AnyRef
+ type B2 <: B1
+ }
+ new Bippy { def apply[T1 <: AnyRef](value: T1) = ??? }
+ new Bippy { type B1 = String ; def apply[T1 <: B1](value: T1) = ??? }
+ new Bippy { type B2 = String ; def apply[T1 <: B2](value: T1) = ??? }
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val xs = new Coll[List[String]]
+ val ys: Coll[Traversable[String]] = xs
+
+ println(ys contains Nil)
+ // java.lang.NoSuchMethodException: Coll$$anon$1.apply(scala.collection.Traversable)
+ // at java.lang.Class.getMethod(Class.java:1605)
+ // at Test$.reflMethod$Method1(a.scala:14)
+ // at Test$.main(a.scala:14)
+ // at Test.main(a.scala)
+ }
+}
diff --git a/test/files/neg/t6566a.check b/test/files/neg/t6566a.check
new file mode 100644
index 0000000000..7668f9d2fb
--- /dev/null
+++ b/test/files/neg/t6566a.check
@@ -0,0 +1,4 @@
+t6566a.scala:2: error: covariant type T occurs in invariant position in type T of type MyType
+ class TypeCheat[+T] { type MyType = T }
+ ^
+one error found
diff --git a/test/files/neg/t6566a.scala b/test/files/neg/t6566a.scala
new file mode 100644
index 0000000000..74a0b38e56
--- /dev/null
+++ b/test/files/neg/t6566a.scala
@@ -0,0 +1,17 @@
+object WhatsYourTypeIsMyType {
+ class TypeCheat[+T] { type MyType = T }
+
+ class Foo {
+ val tc = new TypeCheat[Foo]
+ var x: tc.MyType = _
+ def setX() = x = new Foo
+ }
+ class Bar extends Foo {
+ override val tc = new TypeCheat[Bar]
+ def unsound = this
+
+ setX()
+ println(x.unsound)
+ }
+ def main(args: Array[String]): Unit = new Bar
+}
diff --git a/test/files/neg/t6566b.check b/test/files/neg/t6566b.check
new file mode 100644
index 0000000000..fb3fe81fca
--- /dev/null
+++ b/test/files/neg/t6566b.check
@@ -0,0 +1,4 @@
+t6566b.scala:3: error: covariant type T occurs in invariant position in type T of type MyType
+ type MyType = T
+ ^
+one error found
diff --git a/test/files/neg/t6566b.scala b/test/files/neg/t6566b.scala
new file mode 100644
index 0000000000..18ddebf88b
--- /dev/null
+++ b/test/files/neg/t6566b.scala
@@ -0,0 +1,19 @@
+object WhatsYourTypeIsMyType {
+ trait WithMyType[+T] {
+ type MyType = T
+ }
+
+ class Foo extends WithMyType[Foo] {
+ var x: MyType = _
+ def setX() = x = new Foo
+ }
+
+ class Bar extends Foo with WithMyType[Bar] {
+ def unsound { println("iAmABar") }
+
+ setX()
+ println(x.unsound)
+ }
+
+ def main(args: Array[String]): Unit = new Bar
+}
diff --git a/test/files/neg/variances-refinement.check b/test/files/neg/variances-refinement.check
new file mode 100644
index 0000000000..2bed3ffa6b
--- /dev/null
+++ b/test/files/neg/variances-refinement.check
@@ -0,0 +1,22 @@
+variances-refinement.scala:17: error: contravariant type A occurs in covariant position in type ()AnyRef{def f0(x: A): A} of method fail1
+ def fail1() = { object O { def f0(x: A): A = ??? } ; O } // fail
+ ^
+variances-refinement.scala:18: error: covariant type B occurs in contravariant position in type ()AnyRef{def f0(x: B): A} of method fail2
+ def fail2() = { object O { def f0(x: B): A = ??? } ; O } // fail
+ ^
+variances-refinement.scala:19: error: covariant type B occurs in contravariant position in type ()AnyRef{def f0(x: B): B} of method fail3
+ def fail3() = { object O { def f0(x: B): B = ??? } ; O } // fail
+ ^
+variances-refinement.scala:20: error: covariant type B occurs in contravariant position in type ()AnyRef{def f0(x: B): C} of method fail4
+ def fail4() = { object O { def f0(x: B): C = ??? } ; O } // fail
+ ^
+variances-refinement.scala:21: error: contravariant type A occurs in covariant position in type ()AnyRef{def f0(x: C): A} of method fail5
+ def fail5() = { object O { def f0(x: C): A = ??? } ; O } // fail
+ ^
+variances-refinement.scala:23: error: contravariant type A occurs in covariant position in type ()O1.type forSome { val O1: AnyRef with O0; type O0 <: AnyRef{def f0(x: A): A; def f1(x: A): B; def f2(x: A): C} } of method fail6
+ def fail6() = { // fail
+ ^
+variances-refinement.scala:32: error: contravariant type A occurs in covariant position in type ()AnyRef{def f0(x: A): A; def f1(x: A): B; def f2(x: A): C} of method fail7
+ def fail7() = { // fail
+ ^
+7 errors found
diff --git a/test/files/neg/variances-refinement.scala b/test/files/neg/variances-refinement.scala
new file mode 100644
index 0000000000..6bfd336ce0
--- /dev/null
+++ b/test/files/neg/variances-refinement.scala
@@ -0,0 +1,40 @@
+trait Trait[-A, +B, C] {
+ def ok() = { // ok
+ object O {
+ private def f0(x: A): A = ???
+ def f1(x: A): B = ???
+ def f2(x: A): C = ???
+ private def f3(x: B): A = ???
+ private def f4(x: B): B = ???
+ private def f5(x: B): C = ???
+ private def f6(x: C): A = ???
+ def f7(x: C): B = ???
+ def f8(x: C): C = ???
+ }
+ O
+ }
+
+ def fail1() = { object O { def f0(x: A): A = ??? } ; O } // fail
+ def fail2() = { object O { def f0(x: B): A = ??? } ; O } // fail
+ def fail3() = { object O { def f0(x: B): B = ??? } ; O } // fail
+ def fail4() = { object O { def f0(x: B): C = ??? } ; O } // fail
+ def fail5() = { object O { def f0(x: C): A = ??? } ; O } // fail
+
+ def fail6() = { // fail
+ trait O0 {
+ def f0(x: A): A = ???
+ def f1(x: A): B = ???
+ def f2(x: A): C = ???
+ }
+ object O1 extends O0
+ O1
+ }
+ def fail7() = { // fail
+ trait O0 {
+ def f0(x: A): A = ???
+ def f1(x: A): B = ???
+ def f2(x: A): C = ???
+ }
+ new O0 { }
+ }
+}
diff --git a/test/files/neg/variances.check b/test/files/neg/variances.check
index 0643e533b7..7d965e94dc 100644
--- a/test/files/neg/variances.check
+++ b/test/files/neg/variances.check
@@ -13,7 +13,10 @@ variances.scala:21: error: covariant type A occurs in invariant position in supe
variances.scala:74: error: covariant type A occurs in contravariant position in type => test.Covariant.T[A]{val m: A => A} of value x
val x: T[A] {
^
+variances.scala:89: error: covariant type T occurs in invariant position in type T of type A
+ type A = T
+ ^
variances.scala:90: error: covariant type T occurs in contravariant position in type => test.TestAlias.B[C.this.A] of method foo
def foo: B[A]
^
-6 errors found
+7 errors found
diff --git a/test/files/neg/variances2.check b/test/files/neg/variances2.check
new file mode 100644
index 0000000000..433cc125ad
--- /dev/null
+++ b/test/files/neg/variances2.check
@@ -0,0 +1,229 @@
+variances2.scala:9: error: covariant type B occurs in contravariant position in type B of value x
+ def f1(x: B): Unit = ()
+ ^
+variances2.scala:12: error: covariant type E occurs in contravariant position in type E of value x
+ def f4(x: E): Unit = ()
+ ^
+variances2.scala:15: error: contravariant type A occurs in covariant position in type ()A of method f6
+ def f6(): A = ???
+ ^
+variances2.scala:18: error: contravariant type D occurs in covariant position in type ()D of method f9
+ def f9(): D = ???
+ ^
+variances2.scala:22: error: contravariant type A occurs in covariant position in type A => A of value f
+ def f12(f: A => A): Unit = ()
+ ^
+variances2.scala:23: error: contravariant type A occurs in covariant position in type A => B of value f
+ def f13(f: A => B): Unit = ()
+ ^
+variances2.scala:24: error: contravariant type A occurs in covariant position in type A => C of value f
+ def f14(f: A => C): Unit = ()
+ ^
+variances2.scala:25: error: contravariant type A occurs in covariant position in type A => D of value f
+ def f15(f: A => D): Unit = ()
+ ^
+variances2.scala:26: error: contravariant type A occurs in covariant position in type A => E of value f
+ def f16(f: A => E): Unit = ()
+ ^
+variances2.scala:27: error: contravariant type A occurs in covariant position in type A => F of value f
+ def f17(f: A => F): Unit = ()
+ ^
+variances2.scala:29: error: covariant type B occurs in contravariant position in type B => B of value f
+ def f19(f: B => B): Unit = ()
+ ^
+variances2.scala:32: error: covariant type E occurs in contravariant position in type B => E of value f
+ def f22(f: B => E): Unit = ()
+ ^
+variances2.scala:35: error: covariant type B occurs in contravariant position in type C => B of value f
+ def f25(f: C => B): Unit = ()
+ ^
+variances2.scala:38: error: covariant type E occurs in contravariant position in type C => E of value f
+ def f28(f: C => E): Unit = ()
+ ^
+variances2.scala:40: error: contravariant type D occurs in covariant position in type D => A of value f
+ def f30(f: D => A): Unit = ()
+ ^
+variances2.scala:41: error: contravariant type D occurs in covariant position in type D => B of value f
+ def f31(f: D => B): Unit = ()
+ ^
+variances2.scala:42: error: contravariant type D occurs in covariant position in type D => C of value f
+ def f32(f: D => C): Unit = ()
+ ^
+variances2.scala:43: error: contravariant type D occurs in covariant position in type D => D of value f
+ def f33(f: D => D): Unit = ()
+ ^
+variances2.scala:44: error: contravariant type D occurs in covariant position in type D => E of value f
+ def f34(f: D => E): Unit = ()
+ ^
+variances2.scala:45: error: contravariant type D occurs in covariant position in type D => F of value f
+ def f35(f: D => F): Unit = ()
+ ^
+variances2.scala:47: error: covariant type B occurs in contravariant position in type E => B of value f
+ def f37(f: E => B): Unit = ()
+ ^
+variances2.scala:50: error: covariant type E occurs in contravariant position in type E => E of value f
+ def f40(f: E => E): Unit = ()
+ ^
+variances2.scala:53: error: covariant type B occurs in contravariant position in type F => B of value f
+ def f43(f: F => B): Unit = ()
+ ^
+variances2.scala:56: error: covariant type E occurs in contravariant position in type F => E of value f
+ def f46(f: F => E): Unit = ()
+ ^
+variances2.scala:59: error: contravariant type A occurs in covariant position in type ()A => A of method f48
+ def f48(): A => A = null
+ ^
+variances2.scala:62: error: contravariant type D occurs in covariant position in type ()A => D of method f51
+ def f51(): A => D = null
+ ^
+variances2.scala:65: error: covariant type B occurs in contravariant position in type ()B => A of method f54
+ def f54(): B => A = null
+ ^
+variances2.scala:66: error: covariant type B occurs in contravariant position in type ()B => B of method f55
+ def f55(): B => B = null
+ ^
+variances2.scala:67: error: covariant type B occurs in contravariant position in type ()B => C of method f56
+ def f56(): B => C = null
+ ^
+variances2.scala:68: error: covariant type B occurs in contravariant position in type ()B => D of method f57
+ def f57(): B => D = null
+ ^
+variances2.scala:69: error: covariant type B occurs in contravariant position in type ()B => E of method f58
+ def f58(): B => E = null
+ ^
+variances2.scala:70: error: covariant type B occurs in contravariant position in type ()B => F of method f59
+ def f59(): B => F = null
+ ^
+variances2.scala:71: error: contravariant type A occurs in covariant position in type ()C => A of method f60
+ def f60(): C => A = null
+ ^
+variances2.scala:74: error: contravariant type D occurs in covariant position in type ()C => D of method f63
+ def f63(): C => D = null
+ ^
+variances2.scala:77: error: contravariant type A occurs in covariant position in type ()D => A of method f66
+ def f66(): D => A = null
+ ^
+variances2.scala:80: error: contravariant type D occurs in covariant position in type ()D => D of method f69
+ def f69(): D => D = null
+ ^
+variances2.scala:83: error: covariant type E occurs in contravariant position in type ()E => A of method f72
+ def f72(): E => A = null
+ ^
+variances2.scala:84: error: covariant type E occurs in contravariant position in type ()E => B of method f73
+ def f73(): E => B = null
+ ^
+variances2.scala:85: error: covariant type E occurs in contravariant position in type ()E => C of method f74
+ def f74(): E => C = null
+ ^
+variances2.scala:86: error: covariant type E occurs in contravariant position in type ()E => D of method f75
+ def f75(): E => D = null
+ ^
+variances2.scala:87: error: covariant type E occurs in contravariant position in type ()E => E of method f76
+ def f76(): E => E = null
+ ^
+variances2.scala:88: error: covariant type E occurs in contravariant position in type ()E => F of method f77
+ def f77(): E => F = null
+ ^
+variances2.scala:89: error: contravariant type A occurs in covariant position in type ()F => A of method f78
+ def f78(): F => A = null
+ ^
+variances2.scala:92: error: contravariant type D occurs in covariant position in type ()F => D of method f81
+ def f81(): F => D = null
+ ^
+variances2.scala:96: error: contravariant type A occurs in covariant position in type (x: A)A of method f84
+ def f84(x: A): A = ???
+ ^
+variances2.scala:99: error: contravariant type D occurs in covariant position in type (x: A)D of method f87
+ def f87(x: A): D = ???
+ ^
+variances2.scala:102: error: contravariant type A occurs in covariant position in type (x: B)A of method f90
+ def f90(x: B): A = ???
+ ^
+variances2.scala:102: error: covariant type B occurs in contravariant position in type B of value x
+ def f90(x: B): A = ???
+ ^
+variances2.scala:103: error: covariant type B occurs in contravariant position in type B of value x
+ def f91(x: B): B = ???
+ ^
+variances2.scala:104: error: covariant type B occurs in contravariant position in type B of value x
+ def f92(x: B): C = ???
+ ^
+variances2.scala:105: error: contravariant type D occurs in covariant position in type (x: B)D of method f93
+ def f93(x: B): D = ???
+ ^
+variances2.scala:105: error: covariant type B occurs in contravariant position in type B of value x
+ def f93(x: B): D = ???
+ ^
+variances2.scala:106: error: covariant type B occurs in contravariant position in type B of value x
+ def f94(x: B): E = ???
+ ^
+variances2.scala:107: error: covariant type B occurs in contravariant position in type B of value x
+ def f95(x: B): F = ???
+ ^
+variances2.scala:108: error: contravariant type A occurs in covariant position in type (x: C)A of method f96
+ def f96(x: C): A = ???
+ ^
+variances2.scala:111: error: contravariant type D occurs in covariant position in type (x: C)D of method f99
+ def f99(x: C): D = ???
+ ^
+variances2.scala:114: error: contravariant type A occurs in covariant position in type (x: D)A of method f102
+ def f102(x: D): A = ???
+ ^
+variances2.scala:117: error: contravariant type D occurs in covariant position in type (x: D)D of method f105
+ def f105(x: D): D = ???
+ ^
+variances2.scala:120: error: contravariant type A occurs in covariant position in type (x: E)A of method f108
+ def f108(x: E): A = ???
+ ^
+variances2.scala:120: error: covariant type E occurs in contravariant position in type E of value x
+ def f108(x: E): A = ???
+ ^
+variances2.scala:121: error: covariant type E occurs in contravariant position in type E of value x
+ def f109(x: E): B = ???
+ ^
+variances2.scala:122: error: covariant type E occurs in contravariant position in type E of value x
+ def f110(x: E): C = ???
+ ^
+variances2.scala:123: error: contravariant type D occurs in covariant position in type (x: E)D of method f111
+ def f111(x: E): D = ???
+ ^
+variances2.scala:123: error: covariant type E occurs in contravariant position in type E of value x
+ def f111(x: E): D = ???
+ ^
+variances2.scala:124: error: covariant type E occurs in contravariant position in type E of value x
+ def f112(x: E): E = ???
+ ^
+variances2.scala:125: error: covariant type E occurs in contravariant position in type E of value x
+ def f113(x: E): F = ???
+ ^
+variances2.scala:126: error: contravariant type A occurs in covariant position in type (x: F)A of method f114
+ def f114(x: F): A = ???
+ ^
+variances2.scala:129: error: contravariant type D occurs in covariant position in type (x: F)D of method f117
+ def f117(x: F): D = ???
+ ^
+variances2.scala:133: error: contravariant type A occurs in covariant position in supertype Cov[A] of object O1
+ object O1 extends Cov[A]
+ ^
+variances2.scala:136: error: contravariant type D occurs in covariant position in supertype Cov[D] of object O4
+ object O4 extends Cov[D]
+ ^
+variances2.scala:140: error: covariant type B occurs in contravariant position in supertype Con[B] of object O8
+ object O8 extends Con[B]
+ ^
+variances2.scala:143: error: covariant type E occurs in contravariant position in supertype Con[E] of object O11
+ object O11 extends Con[E]
+ ^
+variances2.scala:145: error: contravariant type A occurs in invariant position in supertype Inv[A] of object O13
+ object O13 extends Inv[A]
+ ^
+variances2.scala:146: error: covariant type B occurs in invariant position in supertype Inv[B] of object O14
+ object O14 extends Inv[B]
+ ^
+variances2.scala:148: error: contravariant type D occurs in invariant position in supertype Inv[D] of object O16
+ object O16 extends Inv[D]
+ ^
+variances2.scala:149: error: covariant type E occurs in invariant position in supertype Inv[E] of object O17
+ object O17 extends Inv[E]
+ ^
+76 errors found
diff --git a/test/files/neg/variances2.scala b/test/files/neg/variances2.scala
new file mode 100644
index 0000000000..d30345dd83
--- /dev/null
+++ b/test/files/neg/variances2.scala
@@ -0,0 +1,303 @@
+trait Cov[+A]
+trait Con[-A]
+trait Inv[A]
+
+trait Trait[-A, +B, C] {
+ // trait Inner[-D <: C, +E >: C, F] {
+ trait Inner[-D <: C, +E >: C, F] {
+ def f0(x: A): Unit = ()
+ def f1(x: B): Unit = ()
+ def f2(x: C): Unit = ()
+ def f3(x: D): Unit = ()
+ def f4(x: E): Unit = ()
+ def f5(x: F): Unit = ()
+
+ def f6(): A = ???
+ def f7(): B = ???
+ def f8(): C = ???
+ def f9(): D = ???
+ def f10(): E = ???
+ def f11(): F = ???
+
+ def f12(f: A => A): Unit = ()
+ def f13(f: A => B): Unit = ()
+ def f14(f: A => C): Unit = ()
+ def f15(f: A => D): Unit = ()
+ def f16(f: A => E): Unit = ()
+ def f17(f: A => F): Unit = ()
+ def f18(f: B => A): Unit = ()
+ def f19(f: B => B): Unit = ()
+ def f20(f: B => C): Unit = ()
+ def f21(f: B => D): Unit = ()
+ def f22(f: B => E): Unit = ()
+ def f23(f: B => F): Unit = ()
+ def f24(f: C => A): Unit = ()
+ def f25(f: C => B): Unit = ()
+ def f26(f: C => C): Unit = ()
+ def f27(f: C => D): Unit = ()
+ def f28(f: C => E): Unit = ()
+ def f29(f: C => F): Unit = ()
+ def f30(f: D => A): Unit = ()
+ def f31(f: D => B): Unit = ()
+ def f32(f: D => C): Unit = ()
+ def f33(f: D => D): Unit = ()
+ def f34(f: D => E): Unit = ()
+ def f35(f: D => F): Unit = ()
+ def f36(f: E => A): Unit = ()
+ def f37(f: E => B): Unit = ()
+ def f38(f: E => C): Unit = ()
+ def f39(f: E => D): Unit = ()
+ def f40(f: E => E): Unit = ()
+ def f41(f: E => F): Unit = ()
+ def f42(f: F => A): Unit = ()
+ def f43(f: F => B): Unit = ()
+ def f44(f: F => C): Unit = ()
+ def f45(f: F => D): Unit = ()
+ def f46(f: F => E): Unit = ()
+ def f47(f: F => F): Unit = ()
+
+ def f48(): A => A = null
+ def f49(): A => B = null
+ def f50(): A => C = null
+ def f51(): A => D = null
+ def f52(): A => E = null
+ def f53(): A => F = null
+ def f54(): B => A = null
+ def f55(): B => B = null
+ def f56(): B => C = null
+ def f57(): B => D = null
+ def f58(): B => E = null
+ def f59(): B => F = null
+ def f60(): C => A = null
+ def f61(): C => B = null
+ def f62(): C => C = null
+ def f63(): C => D = null
+ def f64(): C => E = null
+ def f65(): C => F = null
+ def f66(): D => A = null
+ def f67(): D => B = null
+ def f68(): D => C = null
+ def f69(): D => D = null
+ def f70(): D => E = null
+ def f71(): D => F = null
+ def f72(): E => A = null
+ def f73(): E => B = null
+ def f74(): E => C = null
+ def f75(): E => D = null
+ def f76(): E => E = null
+ def f77(): E => F = null
+ def f78(): F => A = null
+ def f79(): F => B = null
+ def f80(): F => C = null
+ def f81(): F => D = null
+ def f82(): F => E = null
+ def f83(): F => F = null
+
+ def f84(x: A): A = ???
+ def f85(x: A): B = ???
+ def f86(x: A): C = ???
+ def f87(x: A): D = ???
+ def f88(x: A): E = ???
+ def f89(x: A): F = ???
+ def f90(x: B): A = ???
+ def f91(x: B): B = ???
+ def f92(x: B): C = ???
+ def f93(x: B): D = ???
+ def f94(x: B): E = ???
+ def f95(x: B): F = ???
+ def f96(x: C): A = ???
+ def f97(x: C): B = ???
+ def f98(x: C): C = ???
+ def f99(x: C): D = ???
+ def f100(x: C): E = ???
+ def f101(x: C): F = ???
+ def f102(x: D): A = ???
+ def f103(x: D): B = ???
+ def f104(x: D): C = ???
+ def f105(x: D): D = ???
+ def f106(x: D): E = ???
+ def f107(x: D): F = ???
+ def f108(x: E): A = ???
+ def f109(x: E): B = ???
+ def f110(x: E): C = ???
+ def f111(x: E): D = ???
+ def f112(x: E): E = ???
+ def f113(x: E): F = ???
+ def f114(x: F): A = ???
+ def f115(x: F): B = ???
+ def f116(x: F): C = ???
+ def f117(x: F): D = ???
+ def f118(x: F): E = ???
+ def f119(x: F): F = ???
+
+ object O1 extends Cov[A]
+ object O2 extends Cov[B]
+ object O3 extends Cov[C]
+ object O4 extends Cov[D]
+ object O5 extends Cov[E]
+ object O6 extends Cov[F]
+ object O7 extends Con[A]
+ object O8 extends Con[B]
+ object O9 extends Con[C]
+ object O10 extends Con[D]
+ object O11 extends Con[E]
+ object O12 extends Con[F]
+ object O13 extends Inv[A]
+ object O14 extends Inv[B]
+ object O15 extends Inv[C]
+ object O16 extends Inv[D]
+ object O17 extends Inv[E]
+ object O18 extends Inv[F]
+ }
+}
+
+trait Trait2[-A, +B, C] {
+ // trait Inner[-D <: C, +E >: C, F] {
+ def method[D <: A, E >: B, F]() {
+ def f0(x: A): Unit = ()
+ def f1(x: B): Unit = ()
+ def f2(x: C): Unit = ()
+ def f3(x: D): Unit = ()
+ def f4(x: E): Unit = ()
+ def f5(x: F): Unit = ()
+
+ def f6(): A = ???
+ def f7(): B = ???
+ def f8(): C = ???
+ def f9(): D = ???
+ def f10(): E = ???
+ def f11(): F = ???
+
+ def f12(f: A => A): Unit = ()
+ def f13(f: A => B): Unit = ()
+ def f14(f: A => C): Unit = ()
+ def f15(f: A => D): Unit = ()
+ def f16(f: A => E): Unit = ()
+ def f17(f: A => F): Unit = ()
+ def f18(f: B => A): Unit = ()
+ def f19(f: B => B): Unit = ()
+ def f20(f: B => C): Unit = ()
+ def f21(f: B => D): Unit = ()
+ def f22(f: B => E): Unit = ()
+ def f23(f: B => F): Unit = ()
+ def f24(f: C => A): Unit = ()
+ def f25(f: C => B): Unit = ()
+ def f26(f: C => C): Unit = ()
+ def f27(f: C => D): Unit = ()
+ def f28(f: C => E): Unit = ()
+ def f29(f: C => F): Unit = ()
+ def f30(f: D => A): Unit = ()
+ def f31(f: D => B): Unit = ()
+ def f32(f: D => C): Unit = ()
+ def f33(f: D => D): Unit = ()
+ def f34(f: D => E): Unit = ()
+ def f35(f: D => F): Unit = ()
+ def f36(f: E => A): Unit = ()
+ def f37(f: E => B): Unit = ()
+ def f38(f: E => C): Unit = ()
+ def f39(f: E => D): Unit = ()
+ def f40(f: E => E): Unit = ()
+ def f41(f: E => F): Unit = ()
+ def f42(f: F => A): Unit = ()
+ def f43(f: F => B): Unit = ()
+ def f44(f: F => C): Unit = ()
+ def f45(f: F => D): Unit = ()
+ def f46(f: F => E): Unit = ()
+ def f47(f: F => F): Unit = ()
+
+ def f48(): A => A = null
+ def f49(): A => B = null
+ def f50(): A => C = null
+ def f51(): A => D = null
+ def f52(): A => E = null
+ def f53(): A => F = null
+ def f54(): B => A = null
+ def f55(): B => B = null
+ def f56(): B => C = null
+ def f57(): B => D = null
+ def f58(): B => E = null
+ def f59(): B => F = null
+ def f60(): C => A = null
+ def f61(): C => B = null
+ def f62(): C => C = null
+ def f63(): C => D = null
+ def f64(): C => E = null
+ def f65(): C => F = null
+ def f66(): D => A = null
+ def f67(): D => B = null
+ def f68(): D => C = null
+ def f69(): D => D = null
+ def f70(): D => E = null
+ def f71(): D => F = null
+ def f72(): E => A = null
+ def f73(): E => B = null
+ def f74(): E => C = null
+ def f75(): E => D = null
+ def f76(): E => E = null
+ def f77(): E => F = null
+ def f78(): F => A = null
+ def f79(): F => B = null
+ def f80(): F => C = null
+ def f81(): F => D = null
+ def f82(): F => E = null
+ def f83(): F => F = null
+
+ def f84(x: A): A = ???
+ def f85(x: A): B = ???
+ def f86(x: A): C = ???
+ def f87(x: A): D = ???
+ def f88(x: A): E = ???
+ def f89(x: A): F = ???
+ def f90(x: B): A = ???
+ def f91(x: B): B = ???
+ def f92(x: B): C = ???
+ def f93(x: B): D = ???
+ def f94(x: B): E = ???
+ def f95(x: B): F = ???
+ def f96(x: C): A = ???
+ def f97(x: C): B = ???
+ def f98(x: C): C = ???
+ def f99(x: C): D = ???
+ def f100(x: C): E = ???
+ def f101(x: C): F = ???
+ def f102(x: D): A = ???
+ def f103(x: D): B = ???
+ def f104(x: D): C = ???
+ def f105(x: D): D = ???
+ def f106(x: D): E = ???
+ def f107(x: D): F = ???
+ def f108(x: E): A = ???
+ def f109(x: E): B = ???
+ def f110(x: E): C = ???
+ def f111(x: E): D = ???
+ def f112(x: E): E = ???
+ def f113(x: E): F = ???
+ def f114(x: F): A = ???
+ def f115(x: F): B = ???
+ def f116(x: F): C = ???
+ def f117(x: F): D = ???
+ def f118(x: F): E = ???
+ def f119(x: F): F = ???
+
+ object O1 extends Cov[A]
+ object O2 extends Cov[B]
+ object O3 extends Cov[C]
+ object O4 extends Cov[D]
+ object O5 extends Cov[E]
+ object O6 extends Cov[F]
+ object O7 extends Con[A]
+ object O8 extends Con[B]
+ object O9 extends Con[C]
+ object O10 extends Con[D]
+ object O11 extends Con[E]
+ object O12 extends Con[F]
+ object O13 extends Inv[A]
+ object O14 extends Inv[B]
+ object O15 extends Inv[C]
+ object O16 extends Inv[D]
+ object O17 extends Inv[E]
+ object O18 extends Inv[F]
+
+ ()
+ }
+}
diff --git a/test/files/pos/variances-flip.scala b/test/files/pos/variances-flip.scala
new file mode 100644
index 0000000000..c3ea7b571d
--- /dev/null
+++ b/test/files/pos/variances-flip.scala
@@ -0,0 +1,7 @@
+trait Foo[-A, +B, -C, +D] {
+ private[this] def b: B = ???
+ private[this] def d: D = ???
+
+ def f(p1: B => A, p2: D => C) = g(p1(b), p2(d))
+ def g(x: A, y: C) = ((b, d))
+}
diff --git a/test/files/pos/variances-local.scala b/test/files/pos/variances-local.scala
new file mode 100644
index 0000000000..35e395095c
--- /dev/null
+++ b/test/files/pos/variances-local.scala
@@ -0,0 +1,7 @@
+class Foo1[+T] {
+ private[this] type MyType = T
+}
+
+class Foo2[+T] {
+ protected[this] type MyType = T
+}
diff --git a/test/pending/neg/t5378.scala b/test/pending/neg/t5378.scala
deleted file mode 100644
index cada29b0a0..0000000000
--- a/test/pending/neg/t5378.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-import language.reflectiveCalls
-
-class Coll[+T] {
- def contains = new { def apply[T1 <: T](value: T1) = ??? }
-}
-
-object Test {
- def main(args: Array[String]): Unit = {
- val xs = new Coll[List[String]]
- val ys: Coll[Traversable[String]] = xs
-
- println(ys contains Nil)
- // java.lang.NoSuchMethodException: Coll$$anon$1.apply(scala.collection.Traversable)
- // at java.lang.Class.getMethod(Class.java:1605)
- // at Test$.reflMethod$Method1(a.scala:14)
- // at Test$.main(a.scala:14)
- // at Test.main(a.scala)
- }
-}