Skip to content

Quoted pattern unreachable check always fails #6255

Closed
@nicolasstucki

Description

@nicolasstucki
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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions