Skip to content

Valid pattern match on this.type rejected as neither super nor subtype #5787

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
abgruszecki opened this issue Jan 24, 2019 · 1 comment
Closed

Comments

@abgruszecki
Copy link
Contributor

abgruszecki commented Jan 24, 2019

enum Expr[A] {
  case BoolLit(b: Boolean) extends Expr[Boolean]
  def eval: A = {
    def go[AA](self: this.type & Expr[AA]): A = self match {
      case BoolLit(b) => b
    }
    go(this)
  }
}

Error message:

  |Pattern type Expr.BoolLit[A] is neither a subtype nor a supertype of selector type Expr'[A'](Expr'.this) & Expr'[AA]
  |
  |where:    A     is a type variable
  |          A'    is a type in class Expr
  |          Expr  is a object
  |          Expr' is a class

Motivation for why someone would want to do this: it could allow "indirectly" constraining type parameters of enclosing class.

@abgruszecki
Copy link
Contributor Author

Was fixed in #6398.

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