Skip to content

Tuple decomposition in quotes pattern matching doesn't compile #16265

Closed
@prolativ

Description

@prolativ

Compiler version

Fails with: 3.2.1, 3.2.2-RC1-bin-20221030-eab19e3-NIGHTLY
Used to work with 3.2.0

Minimized code

//> using scala "3.2.1"

import scala.quoted.*

class Foo(val value: Int)
  
def foo(exprs: Expr[Any])(using Quotes): Any =
  exprs match
    case '{ $tuple: (Foo *: tail) } =>
      val x = '{ ${tuple}.head.value }
      ???

Output

[error] ./repro/Macro.scala:10:18: undefined: ${
[error]   {
[error]     def $anonfun(using evidence$1: quoted.Quotes): quoted.Expr[(Foo *: tail)] = 
[error]       tuple
[error]     closure($anonfun)
[error]   }
[error] }.head[(Foo *: tail)].value.$asInstanceOf # -1: TermRef(TermRef(AppliedType(TypeRef(TermRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Tuple),Head),List(AppliedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class *:),List(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class Foo), TypeRef(NoPrefix,type tail))))),value),$asInstanceOf$) at sbt-api
[error]       val x = '{ ${tuple}.head.value }
[error]

Expectation

Should compile, as in 3.2.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions