Skip to content

Error while compiling macro inline argument used in quote #4455

Closed
@nicolasstucki

Description

@nicolasstucki
import scala.quoted._
object Macros {
  inline def foo(inline i: Int): Int = ~bar('(i))
  def bar(x: Expr[Int]): Expr[Int] = ???
}
exception while typing Macros.bar(i$1) of class class dotty.tools.dotc.ast.Trees$Apply # 175
exception while typing {
  val i$1: Int = x$0.apply(0).asInstanceOf[Int]
  Macros.bar(i$1)
} of class class dotty.tools.dotc.ast.Trees$Block # 176
exception while typing def $anonfun$1(x$0: Seq[Any]): quoted.Expr[Int] = 
  {
    val i$1: Int = x$0.apply(0).asInstanceOf[Int]
    Macros.bar(i$1)
  } of class class dotty.tools.dotc.ast.Trees$DefDef # 180
exception while typing {
  def $anonfun$1(x$0: Seq[Any]): quoted.Expr[Int] = 
    {
      val i$1: Int = x$0.apply(0).asInstanceOf[Int]
      Macros.bar(i$1)
    }
  closure($anonfun$1)
}

We should probably add a .toExpr to inlined references that are inside of a quote https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala#L549

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions