Closed
Description
Minimized code
import scala.quoted._
object Test {
given staging.Compiler = staging.Compiler.make(getClass.getClassLoader)
def main(args: Array[String]): Unit =
staging.run {
'{ foo() }
}
inline def foo(): Unit = ${ fooExpr() }
private def fooExpr()(using Quotes): Expr[Unit] = '{ println("foo") }
}
Output
exception while typing scala.quoted.runtime.Expr.splice of class class dotty.tools.dotc.ast.Trees$Ident # -1
exception while typing scala.quoted.runtime.Expr.splice[Unit] of class class dotty.tools.dotc.ast.Trees$TypeApply # -1
exception while typing ${
{
def $anonfun(using evidence$2: quoted.Quotes): quoted.Expr[Unit] =
Test.inline$fooExpr()(evidence$2)
closure($anonfun)
}
} of class class dotty.tools.dotc.ast.Trees$Apply # -1
exception while typing ${
{
def $anonfun(using evidence$2: quoted.Quotes): quoted.Expr[Unit] =
Test.inline$fooExpr()(evidence$2)
closure($anonfun)
}
}:Unit of class class dotty.tools.dotc.ast.Trees$Typed # -1
exception while typing ${
{
def $anonfun(using evidence$2: quoted.Quotes): quoted.Expr[Unit] =
Test.inline$fooExpr()(evidence$2)
closure($anonfun)
}
}:Unit of class class dotty.tools.dotc.ast.Trees$Inlined # -1
exception while typing ${
{
def $anonfun(using evidence$2: quoted.Quotes): quoted.Expr[Unit] =
Test.inline$fooExpr()(evidence$2)
closure($anonfun)
}
}:Unit of class class dotty.tools.dotc.ast.Trees$Inlined # -1
exception while typing def apply: Any =
${
{
def $anonfun(using evidence$2: quoted.Quotes): quoted.Expr[Unit] =
Test.inline$fooExpr()(evidence$2)
closure($anonfun)
}
}:Unit of class class dotty.tools.dotc.ast.Trees$DefDef # -1
exception while typing class Generated$Code$From$Quoted() extends Object() {
def apply: Any =
${
{
def $anonfun(using evidence$2: quoted.Quotes): quoted.Expr[Unit] =
Test.inline$fooExpr()(evidence$2)
closure($anonfun)
}
}:Unit
} of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
exception while typing package _root_ {
class Generated$Code$From$Quoted() extends Object() {
def apply: Any =
${
{
def $anonfun(using evidence$2: quoted.Quotes): quoted.Expr[Unit] =
Test.inline$fooExpr()(evidence$2)
closure($anonfun)
}
}:Unit
}
} of class class dotty.tools.dotc.ast.Trees$PackageDef # -1
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at dotty.tools.vulpix.ChildJVMMain.runMain(ChildJVMMain.java:40)
at dotty.tools.vulpix.ChildJVMMain.main(ChildJVMMain.java:47)
Caused by: class dotty.tools.dotc.reporting.Diagnostic$Error at tests/run-staging/i11152.scala:<226..226>: Illegal reference to `scala.quoted.runtime.Expr.splice`
at dotty.tools.dotc.report$.error(report.scala:71)
at dotty.tools.dotc.transform.Erasure$Typer.checkNotErased(Erasure.scala:594)
at dotty.tools.dotc.transform.Erasure$Typer.typedIdent(Erasure.scala:647)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2521)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2613)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2799)
at dotty.tools.dotc.transform.Erasure$Typer.typedTypeApply(Erasure.scala:792)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2571)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2614)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2799)
at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:814)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2552)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2614)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.transform.Erasure$Typer.typedTyped(Erasure.scala:629)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2557)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2614)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.typedInlined(Typer.scala:1697)
at dotty.tools.dotc.transform.Erasure$Typer.typedInlined(Erasure.scala:876)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2574)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2614)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.typedInlined(Typer.scala:1697)
at dotty.tools.dotc.transform.Erasure$Typer.typedInlined(Erasure.scala:876)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2574)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2614)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2676)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2799)
at dotty.tools.dotc.typer.Typer.$anonfun$33(Typer.scala:2056)
at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:219)
at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2056)
at dotty.tools.dotc.transform.Erasure$Typer.typedDefDef(Erasure.scala:929)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2529)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2613)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2705)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2755)
at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1037)
at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2202)
at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1026)
at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2540)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2544)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2613)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2705)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2755)
at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1037)
at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2337)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2585)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2614)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2799)
at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:124)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:300)
at scala.collection.immutable.List.map(List.scala:246)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:301)
at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:185)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
at dotty.tools.dotc.Run.runPhases$5(Run.scala:195)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:203)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
at dotty.tools.dotc.Run.compileUnits(Run.scala:210)
at dotty.tools.dotc.Run.compileUnits(Run.scala:152)
at scala.quoted.staging.QuoteCompiler$ExprRun.compileExpr(QuoteCompiler.scala:111)
at scala.quoted.staging.QuoteDriver.run(QuoteDriver.scala:39)
at scala.quoted.staging.Compiler$$anon$1.run(Compiler.scala:38)
at scala.quoted.staging.package$.run(staging.scala:19)
at Test$.main(i11152.scala:11)
at Test.main(i11152.scala)
... 6 more
Expectation
Should evaluate the macro in the Inlining
phase.