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

validate bounds of HK type args against parameter bounds #7318

Closed
scabug opened this issue Mar 31, 2013 · 2 comments
Closed

validate bounds of HK type args against parameter bounds #7318

scabug opened this issue Mar 31, 2013 · 2 comments

Comments

@scabug
Copy link

scabug commented Mar 31, 2013

object Test {
  def foo[B[X <: B[X]]] = 0
  foo[List] // incorrectly allowed

  def baz[B[X <: String]] = 0
  baz[List] // incorrectly allowed

  def bar[B[+X]] = 0
  class C[X]
  bar[C] // correctly rejected.
}

From Infer#checkBounds:

        //@M validate variances & bounds of targs wrt variances & bounds of tparams
        //@M TODO: better place to check this?
        //@M TODO: errors for getters & setters are reported separately
        val kindErrors = checkKindBounds(tparams, targs, pre, owner)
        kindErrors match {
@scabug
Copy link
Author

scabug commented Mar 31, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7318?orig=1
Reporter: @retronym
Affected Versions: 2.10.0

@scabug
Copy link
Author

scabug commented Mar 31, 2013

@retronym said:
Wait, I've got things upside down.. Maybe the comments are outdated, but the behaviour is okay.

  class A[X <: String]
  def baz[B[X <: Any]] = { type T = B[Any] }
  baz[A] // correctly rejected, otherwise T would be A[Any]

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

1 participant