Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plug many variance holes (pos and neg)
- Loading branch information
Showing
8 changed files
with
158 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
t7872.scala:5: error: contravariant type a occurs in covariant position in type [-a]Cov[a] of type l | ||
type l[-a] = Cov[a] | ||
^ | ||
t7872.scala:6: error: contravariant type a occurs in covariant position in type [-a]Cov[a] of type l | ||
type x = {type l[-a] = Cov[a]} | ||
^ | ||
t7872.scala:8: error: covariant type a occurs in contravariant position in type [+a]Inv[a] of type l | ||
t7872.scala:8: error: covariant type a occurs in contravariant position in type [+a]Inv[a] of value <local l> | ||
foo[({type l[+a] = Inv[a]})#l] | ||
^ | ||
t7872.scala:5: error: contravariant type a occurs in covariant position in type [-a]Cov[a] of type l | ||
type l[-a] = Cov[a] | ||
^ | ||
three errors found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
t7872b.scala:8: error: contravariant type a occurs in covariant position in type [-a]List[a] of type l | ||
t7872b.scala:8: error: contravariant type a occurs in covariant position in type [-a]List[a] of value <local l> | ||
def oops1 = down[({type l[-a] = List[a]})#l](List('whatever: Object)).head + "oops" | ||
^ | ||
t7872b.scala:19: error: covariant type a occurs in contravariant position in type [+a]coinv.Stringer[a] of type l | ||
t7872b.scala:19: error: covariant type a occurs in contravariant position in type [+a]a => String of value <local l> | ||
def oops2 = up[({type l[+a] = Stringer[a]})#l]("printed: " + _) | ||
^ | ||
two errors found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
variance-holes.scala:9: error: covariant type x occurs in contravariant position in type [+x, +y] >: F[x,y] of type F2 | ||
def asWiden[F2[+x, +y] >: F[x, y]]: F2[Int, Int] = v | ||
^ | ||
variance-holes.scala:2: error: contravariant type A occurs in covariant position in type [-A] >: List[A] of type Lower1 | ||
type Lower1[-A] >: List[A] | ||
^ | ||
variance-holes.scala:5: error: covariant type x occurs in contravariant position in type [+x] >: F[x] of type G | ||
type G[+x] >: F[x] | ||
^ | ||
variance-holes.scala:13: error: covariant type A occurs in contravariant position in type => AnyRef{type T >: A} of method foo | ||
def foo: { type T >: A } | ||
^ | ||
variance-holes.scala:17: error: covariant type A occurs in contravariant position in type AnyRef{type T <: A} of value x | ||
def foo(x: { type T <: A }): Unit | ||
^ | ||
variance-holes.scala:20: error: covariant type A occurs in contravariant position in type [+A]AnyRef { | ||
def <init>(): Test.Refined3[A] | ||
} of class Refined3 | ||
class Refined3[+A] { | ||
^ | ||
variance-holes.scala:24: error: covariant type A occurs in contravariant position in type <: AnyRef{type T >: A} of type x | ||
class RefinedLower[+A, x <: { type T >: A }] | ||
^ | ||
variance-holes.scala:25: error: covariant type A occurs in contravariant position in type A of value x_= | ||
private[this] class PrivateThis[+A](var x: A) | ||
^ | ||
8 errors found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
object Test { | ||
type Lower1[-A] >: List[A] | ||
|
||
class Lower2[F[-_]] { | ||
type G[+x] >: F[x] | ||
} | ||
|
||
class Lower3[F[-_, -_]](v: F[Int, Int]) { | ||
def asWiden[F2[+x, +y] >: F[x, y]]: F2[Int, Int] = v | ||
} | ||
|
||
trait Refined1[+A] { | ||
def foo: { type T >: A } | ||
} | ||
|
||
trait Refined2[+A] { | ||
def foo(x: { type T <: A }): Unit | ||
} | ||
|
||
class Refined3[+A] { | ||
generic[{ type T <: A } => Int] | ||
} | ||
|
||
class RefinedLower[+A, x <: { type T >: A }] | ||
private[this] class PrivateThis[+A](var x: A) | ||
|
||
def generic[A]: Unit = () | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
object Test { | ||
type Lower1[+A] >: List[A] | ||
|
||
class Lower2[F[+_]] { | ||
type G[+x] >: F[x] | ||
} | ||
|
||
class Lower3[F[+_, +_]](v: F[Int, Int]) { | ||
def asWiden[F2[+x, +y] >: F[x, y]]: F2[Int, Int] = v | ||
} | ||
|
||
trait Refined1[+A] { | ||
def foo: { type T <: A } | ||
} | ||
|
||
trait Refined2[+A] { | ||
def foo(x: { type T >: A }): Unit | ||
} | ||
|
||
class Refined3[+A] { | ||
generic[{ type T >: A } => Int] | ||
} | ||
|
||
class RefinedUpper1[+A, x <: { type T <: A }] | ||
class RefinedUpper2[+A, x <: { type T[_ <: A] }] | ||
trait RefinedLower[+A, x <: { type T[_ >: A] }] | ||
|
||
class PrivateThis[+A] { | ||
private[this] object Foo { var x: A = _ } | ||
} | ||
|
||
def generic[A]: Unit = () | ||
} |