Skip to content

Wrong lower type bound is accepted #4369

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

Closed
sir-wabbit opened this issue Apr 25, 2018 · 1 comment
Closed

Wrong lower type bound is accepted #4369

sir-wabbit opened this issue Apr 25, 2018 · 1 comment

Comments

@sir-wabbit
Copy link

sir-wabbit commented Apr 25, 2018

trait X[R <: Z, Z >: X[R, R]] {
  // def foo(x: X[R, R]): Z = x
}
class Z extends X[Z, Z]

Somehow this compiles, even though foo doesn't. Note that class Z is not a super type of X[Z, Z], which is required by the second type parameter of trait X.

trait X[R <: Z, Z >: X[R, R] <: X[R, R]] {
  // implicitly[Z =:= X[R, R]] // won't compile
}
class Z extends X[Z, Z]
@sir-wabbit
Copy link
Author

sir-wabbit commented Apr 25, 2018

This might be related to #4368 since encoding the above snippet using type members:

trait X { self =>
  type R <: Z
  type Z >: X { type R = self.R; type Z = self.R }
}
class Foo extends X { type R = Foo; type Z = Foo }

causes stack overflow.

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

No branches or pull requests

6 participants