-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Crash on casting with isInstanceOf
from a quote
#6997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
It can be minimized to import scala.quoted._
class Foo {
def mcrImpl(body: Expr[Any]) given (t: Type[_ <: Any]) given (ctx: QuoteContext): Expr[Any] = '{
val tmp = $body.asInstanceOf[$t]
tmp
}
} The issue is that ReifyQuotes is not able to handle a splice of CrashException in thread "main" java.lang.AssertionError: assertion failed: unresolved symbols: value t(line 3) when pickling Foo.scala
at dotty.DottyPredef$.assertFail(DottyPredef.scala:16)
at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:695)
at dotty.tools.dotc.core.quoted.PickledQuotes$.pickle(PickledQuotes.scala:89)
at dotty.tools.dotc.core.quoted.PickledQuotes$.pickleQuote(PickledQuotes.scala:32)
at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.pickleAsTasty$1(ReifyQuotes.scala:237)
at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.pickledQuote(ReifyQuotes.scala:249)
at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transformQuotation(ReifyQuotes.scala:195)
at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:94)
at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:409)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1255)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:118)
at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:77)
at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:127)
at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:409)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1261)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:118)
at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:77)
at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:127)
at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:409)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:98)
at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:77)
at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:127)
at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:409)
at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:52)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:59)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:109)
at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:77)
at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:127)
at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:409)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1331)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:102)
at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:77)
at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:127)
at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:409)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$2(Trees.scala:1351)
at scala.collection.immutable.List.mapConserve(List.scala:179)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1351)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1349)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1337)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:102)
at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:77)
at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:127)
at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:409)
at dotty.tools.dotc.transform.ReifyQuotes$$anon$1.transform(ReifyQuotes.scala:94)
at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:21)
at dotty.tools.dotc.transform.ReifyQuotes.run(ReifyQuotes.scala:90)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:316)
at scala.collection.immutable.List.map(List.scala:286)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:318)
at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:158)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
at dotty.tools.dotc.Run.runPhases$5(Run.scala:170)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:178)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
at dotty.tools.dotc.Run.compileUnits(Run.scala:185)
at dotty.tools.dotc.Run.compileSources(Run.scala:120)
at dotty.tools.dotc.Run.compile(Run.scala:104)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
at dotty.tools.dotc.Driver.process(Driver.scala:180)
at dotty.tools.dotc.Driver.process(Driver.scala:149)
at dotty.tools.dotc.Driver.process(Driver.scala:161)
at dotty.tools.dotc.Driver.main(Driver.scala:188)
at dotty.tools.dotc.Main.main(Main.scala) |
isInstanceOf
from a quote
Actually adding the following ascription fixes it import scala.quoted._
class Foo {
def mcrImpl(body: Expr[Any]) given (t: Type[_ <: Any]) given (ctx: QuoteContext): Expr[Any] = '{
val tmp = $body.asInstanceOf[$t]
tmp: $t
}
} a similar type ascription is added ( |
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Aug 7, 2019
odersky
added a commit
that referenced
this issue
Aug 23, 2019
Fix #6997: Adapt quote type direct aliase to type splice
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Macro:
Main:
Error:
If you uncomment the cast as follows:
The compiler crashes:
Crash
The text was updated successfully, but these errors were encountered: