File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -41,4 +41,19 @@ object Test2 extends App {
41
41
}
42
42
43
43
44
+ trait HasY { type Y }
45
+
46
+ // These are neg-tests corresponding to the pos-test Variances.scala
47
+ // where all the variance annotations have been inverted.
48
+ trait Foo1 [+ X ] { def bar [Y <: X ](y : Y ) = y } // error
49
+ trait Foo2 [+ X ] { def bar (x : HasY { type Y <: X })(y : x.Y ) = y } // error
50
+ trait Foo3 [- X ] { def bar [Y >: X ](y : Y ) = y } // error
51
+ trait Foo4 [- X ] { def bar (x : HasY { type Y >: X })(y : x.Y ) = y } // error
52
+
53
+ // These are neg-tests corresponding to the pos-test Variances.scala
54
+ // where all the bounds have been flipped.
55
+ trait Foo5 [- X ] { def bar [Y >: X ](y : Y ) = y } // error
56
+ trait Foo6 [- X ] { def bar (x : HasY { type Y >: X })(y : x.Y ) = y } // error
57
+ trait Foo7 [+ X ] { def bar [Y <: X ](y : Y ) = y } // error
58
+ trait Foo8 [+ X ] { def bar (x : HasY { type Y <: X })(y : x.Y ) = y } // error
44
59
Original file line number Diff line number Diff line change 1
1
trait C [+ T <: C [T , U ], - U <: C [T , U ]] {
2
2
3
3
}
4
+ trait HasY { type Y }
5
+
6
+ // This works in scalac.
7
+ trait Foo1 [- X ] { def bar [Y <: X ](y : Y ) = y }
8
+
9
+ // A variant of Foo1 using a dependent method type (doesn't work using
10
+ // scalac)
11
+ trait Foo2 [- X ] { def bar (x : HasY { type Y <: X })(y : x.Y ) = y }
12
+
13
+ // This works in scalac.
14
+ trait Foo3 [+ X ] { def bar [Y >: X ](y : Y ) = y }
15
+
16
+ // A variant of Foo3 using a dependent method type (doesn't work
17
+ // using scalac)
18
+ trait Foo4 [+ X ] { def bar (x : HasY { type Y >: X })(y : x.Y ) = y }
You can’t perform that action at this time.
0 commit comments