Skip to content

Quoted pattern failing as a val extractor #6435

Closed
@nicolasstucki

Description

@nicolasstucki

The following works

import scala.quoted._
import scala.quoted.matching._
def f(sc: quoted.Expr[StringContext]) given tasty.Reflection: Unit = {
  sc match {
    case '{ StringContext(${ExprSeq(parts)}: _*) } =>
      val ps: Seq[Expr[String]] = parts
  }
}

but rewiting it to

import scala.quoted._
import scala.quoted.matching._
def f(sc: quoted.Expr[StringContext]) given tasty.Reflection: Unit = {
  val '{ StringContext(${ExprSeq(parts)}: _*) } = sc
  val ps: Seq[Expr[String]] = parts
}

fails with

15 |      val ps: Seq[Expr[String]] = parts
   |                                  ^^^^^
   |                                  Not found: parts

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions