Skip to content

Match fails using quasiquotes #8600

Closed
@Blaisorblade

Description

@Blaisorblade

The issue is described in https://users.scala-lang.org/t/implementing-map-fusion-with-dotty-macros/5791/4?u=blaisorblade — sorry for not minimizing it further. Basically, the match in

  def mapImpl[A: Type, B: Type] (first: Expr[Pipe[A]], fn: Expr[A => B])(using qctx: QuoteContext): Expr[Pipe[B]] = {
    first match {
      case '{ Mapped($iFirst, $iFn) } =>
        '{ Mapped($iFirst, $iFn andThen $fn) }
      case _ =>
        '{ Mapped($first, $fn) }
    }
  }

fails to match against Mapped(foo, bar) (as produced by macro Source(List(1, 2, 3)).map(x => x + 1)). Using tasty reflection, I can make that match work by stripping Typed and Inlined nodes.
Additionally, I wanted to match against TypeApply by something like
case '{ Mapped[$A, $B]($iFirst, $iFn) } => (or using _ for $A), but I could not find a working syntax to express that.

To reproduce, check out https://github.com/Blaisorblade/dotty-map-fusion-staging-experiment.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions