Closed
Description
Summoning during the Inlining
phase fails. We are not tracking the implicits in scope. See TreeMapWithImplicits
Minimized code
import scala.quoted._
object Test {
given staging.Compiler = staging.Compiler.make(getClass.getClassLoader)
// given staging.Toolbox = staging.Toolbox.make(getClass.getClassLoader)
def main(args: Array[String]): Unit = staging.run {
'{
given Int = 10
compiletime.summonInline[Int]
()
}
}
}
Output
exception while typing implicit match
{
case t @ _:Int =>
t:Int
} of class class dotty.tools.dotc.ast.Trees$InlineMatch # -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 library/src/scala/compiletime/package.scala:[4482..4506]: cannot reduce summonFrom with
patterns : case t @ _:Int
at dotty.tools.dotc.report$.error(report.scala:71)
at dotty.tools.dotc.typer.ErrorReporting$.errorType(ErrorReporting.scala:34)
at dotty.tools.dotc.typer.ErrorReporting$.errorTree(ErrorReporting.scala:25)
at dotty.tools.dotc.typer.ErrorReporting$.errorTree(ErrorReporting.scala:28)
at dotty.tools.dotc.typer.Inliner$InlineTyper.typedMatchFinish(Inliner.scala:1329)
at dotty.tools.dotc.typer.Typer.typedMatch(Typer.scala:1362)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2566)
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.Inliner.inlined(Inliner.scala:784)
at dotty.tools.dotc.typer.Inliner$.inlineCall(Inliner.scala:126)
at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:68)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1414)
at scala.collection.immutable.List.mapConserve(List.scala:472)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1414)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1412)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1327)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:63)
at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:65)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1347)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:63)
at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:77)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1386)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:54)
at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:63)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transformStat$1(MacroTransform.scala:42)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transformStats$$anonfun$1(MacroTransform.scala:45)
at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:92)
at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:108)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transformStats(MacroTransform.scala:45)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:61)
at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:63)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1390)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:54)
at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:63)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1414)
at scala.collection.immutable.List.mapConserve(List.scala:472)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1414)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1412)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1399)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:54)
at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:77)
at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:21)
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.Toolbox$$anon$1.run(Toolbox.scala:38)
at scala.quoted.staging.package$.run(staging.scala:19)
at Test$.main(inline-class-def.scala:17)
at Test.main(inline-class-def.scala)
Expectation
Should compile and run