Skip to content

Quoted match on an exported definition? (matching the "original" definition) #12959

Open
@deusaquilus

Description

@deusaquilus

Compiler version

Latest Nightly: scala-3.0.2-RC1-bin-20210626-f33bc8d-NIGHTLY

Minimized code

Create a global function in a namespace (e.g. Dsl). Then export it:

package io.getquill.mytest

object Dsl:
  def stuff: String = ???

export Dsl._

Then make a quoted-match clause to match it:

object ParseMacro:
  inline def parse(inline any: Any): Unit = ${ parseImpl('any) }
  def parseImpl(any: Expr[Any])(using Quotes): Expr[Unit] =
    import quotes.reflect._
    any match
      case '{ Dsl.stuff } => println("Matched!")
      case _ => println("Did not match")
    '{ () }

Then use the macro to match it based on the export:

import mytest._
ParseMacro.parse(stuff)

It will not match.

Output

The clause does not match i.e. Did not match is printed.

Expectation

The clause should match the exported symbol.

Repo

Example code can be found here:
https://github.com/deusaquilus/export_match_issue

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions