Skip to content

Cannot parameterize inline macro  #4023

Closed
@nicolasstucki

Description

@nicolasstucki
import scala.quoted._
object Macro {
  inline def ff[T](x: T): T = ~impl[T]('(x))
  def impl[T](x: Expr[T]): Expr[T] = x
}

fails with

3 |  inline def ff[T](x: T): T = ~impl[T]('(x))
  |                                    ^
  |              access to type T from wrong staging level:
  |               - the definition is at level 1,
  |               - but the access is at level 0.
  |              
  |               The access would be accepted with the right type tag, but
  |               no implicit argument of type scala.quoted.Type[T] was found

But if we add the implicit quoted.Type[T] it fails with

3 |  inline def ff[T: Type](x: T): T = ~impl[T]('(x))
  |                                     ^
  |                      access to value evidence$1 from wrong staging level:
  |                       - the definition is at level 1,
  |                       - but the access is at level -1.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions