Skip to content

Quoted pattern unreachable check always fails #6255

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
nicolasstucki opened this issue Apr 7, 2019 · 0 comments
Closed

Quoted pattern unreachable check always fails #6255

nicolasstucki opened this issue Apr 7, 2019 · 0 comments

Comments

@nicolasstucki
Copy link
Contributor

class Foo {
  def foo(x: quoted.Expr[Int]) given scala.tasty.Reflection: Unit = x match {
    case '{ 1 } =>
    case '{ 2 } =>
    case _ =>
  }
}

which is transformed in typer to

package <empty> {
  class Foo() extends Object() { 
    def foo(x: quoted.Expr[Int])(implicit x$2: scala.tasty.Reflection): Unit = 
      x match 
        {
          case scala.internal.quoted.Matcher.unapply[Unit](())('{1}, x$2) => 
            ()
          case scala.internal.quoted.Matcher.unapply[Unit](())('{2}, x$2) => 
            ()
          case _ => 
            ()
        }
  }
}

Where the patterns become part of the implicit arguments of the unapply.

The second case is considered as unreachable even when they differ in their parameters.

-- [E030] Match case Unreachable Warning: Foo.scala:4:9 ------------------------
4 |    case '{ 2 } =>
  |         ^^^^
  |         Unreachable case
liufengyun added a commit to dotty-staging/dotty that referenced this issue Apr 8, 2019
This seems to be the best strategy for now, given that
quotes are the implicit args trick is only used for
matching Expr[T], and `case _ =>` is always used in such
cases.

Otherwise, we will need to reason equality of Terms, which is subtle.
liufengyun added a commit to dotty-staging/dotty that referenced this issue Apr 8, 2019
This seems to be the best strategy for now, given that
the implicit args trick is only used for matching Expr[T],
and `case _ =>` is always used in such cases.

Otherwise, we will need to reason equality of Terms, which is subtle.
liufengyun added a commit that referenced this issue Apr 10, 2019
Fix #6255: Don't check unreachability for Expr[T]
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

2 participants