Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variance checking inconsistency when using type members in refinement types in argument position #9725

Closed
scabug opened this issue Mar 29, 2016 · 2 comments · Fixed by scala/scala#8545
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Mar 29, 2016

trait Foo1[-X] { def bar[Y <: X](y: Y) = y } // typechecks

// A variant of Foo1 encoding the type parameter Y using a dependent method type.
// error: contravariant type X occurs in covariant position in type  <: X of type Y
trait Foo2[-X] { def bar(x: { type Y <: X })(y: x.Y) = y } 

trait Foo3[+X] { def bar[Y >: X](y: Y) = y } // typechecks

// A variant of Foo3 using a dependent method type.
// error: covariant type X occurs in contravariant position in type  >: X of type Y
trait Foo4[+X] { def bar(x: { type Y >: X })(y: x.Y) = y }

The errors appear even if we don't use dependent method types.

// error: covariant type X occurs in contravariant position in type  >: X of type Y
trait Foo9[+X] { def bar(x: { type Y >: X }): Any }
@scabug
Copy link
Author

scabug commented Mar 29, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9725?orig=1
Reporter: @sstucki
Affected Versions: 2.11.8

@scabug
Copy link
Author

scabug commented Mar 30, 2016

@DarkDimius said:
Those tests pass in Dotty: scala/scala3#1190

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants