Skip to content

unresolved symbol in REPL when referencing quoted type in another quote #9891

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

Closed
bishabosha opened this issue Sep 26, 2020 · 2 comments · Fixed by #15359
Closed

unresolved symbol in REPL when referencing quoted type in another quote #9891

bishabosha opened this issue Sep 26, 2020 · 2 comments · Fixed by #15359
Assignees

Comments

@bishabosha
Copy link
Member

Minimized code

The following example compiles with dotc 0.27.0-RC1, but crashes in the REPL

(it is part of the example taken from the docs for implementing type class derivation with macros)

import quoted._                                                                                                  
import deriving.Mirror
def derived[T: Type](using qctx: QuoteContext): Expr[Any] = {
  import qctx.tasty._
  val ev: Expr[Mirror.Of[T]] = Expr.summon(using '[Mirror.Of[T]]).get
  '{null}
}

Output [REPL crash] (click arrow to expand)

Starting dotty REPL...
scala> import quoted._                                                                                                  
     | import deriving.Mirror
     | 
     | def derived[T: Type](using qctx: QuoteContext): Expr[Any] = {
     |   import qctx.tasty._
     |   val ev: Expr[Mirror.Of[T]] = Expr.summon(using '[Mirror.Of[T]]).get
     |   '{null}
     | }
Exception in thread "main" java.lang.AssertionError: assertion failed: unresolved symbols: type T(line 3) when pickling rs$line$1
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
	at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:738)
	at dotty.tools.dotc.quoted.PickledQuotes$.pickle(PickledQuotes.scala:168)
	at dotty.tools.dotc.quoted.PickledQuotes$.pickleQuote(PickledQuotes.scala:34)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.pickleAsTasty$1(ReifyQuotes.scala:173)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.pickledQuote(ReifyQuotes.scala:182)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transformQuotation(ReifyQuotes.scala:139)
	at dotty.tools.dotc.transform.TreeMapWithStages.op$proxy1$1(TreeMapWithStages.scala:114)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:150)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.op$proxy2$1(ReifyQuotes.scala:396)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:398)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1262)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:121)
	at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:85)
	at dotty.tools.dotc.transform.TreeMapWithStages.op$proxy1$1(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:150)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.op$proxy2$1(ReifyQuotes.scala:396)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:398)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1268)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:121)
	at dotty.tools.dotc.transform.TreeMapWithStages.op$proxy1$1(TreeMapWithStages.scala:104)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:150)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.op$proxy2$1(ReifyQuotes.scala:396)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:398)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$2(Trees.scala:1367)
	at scala.collection.immutable.List.mapConserve(List.scala:472)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1367)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1268)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:121)
	at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:85)
	at dotty.tools.dotc.transform.TreeMapWithStages.op$proxy1$1(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:150)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.op$proxy2$1(ReifyQuotes.scala:396)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:398)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1268)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:121)
	at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:85)
	at dotty.tools.dotc.transform.TreeMapWithStages.op$proxy1$1(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:150)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.op$proxy2$1(ReifyQuotes.scala:396)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:398)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1262)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:121)
	at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:85)
	at dotty.tools.dotc.transform.TreeMapWithStages.op$proxy1$1(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:150)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.op$proxy2$1(ReifyQuotes.scala:396)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:398)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1336)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:105)
	at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:85)
	at dotty.tools.dotc.transform.TreeMapWithStages.op$proxy1$1(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:150)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.op$proxy2$1(ReifyQuotes.scala:396)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:398)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$2(Trees.scala:1367)
	at scala.collection.immutable.List.mapConserve(List.scala:472)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1367)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1365)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1282)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:92)
	at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:85)
	at dotty.tools.dotc.transform.TreeMapWithStages.op$proxy1$1(TreeMapWithStages.scala:136)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:150)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.op$proxy2$1(ReifyQuotes.scala:396)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:398)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:100)
	at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:85)
	at dotty.tools.dotc.transform.TreeMapWithStages.op$proxy1$1(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:150)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.op$proxy2$1(ReifyQuotes.scala:396)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:398)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:112)
	at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:85)
	at dotty.tools.dotc.transform.TreeMapWithStages.op$proxy1$1(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:150)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.op$proxy2$1(ReifyQuotes.scala:396)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:398)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1345)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:105)
	at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:85)
	at dotty.tools.dotc.transform.TreeMapWithStages.op$proxy1$1(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:150)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.op$proxy2$1(ReifyQuotes.scala:396)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:398)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$2(Trees.scala:1367)
	at scala.collection.immutable.List.mapConserve(List.scala:472)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1367)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1365)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1352)
	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:105)
	at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:85)
	at dotty.tools.dotc.transform.TreeMapWithStages.op$proxy1$1(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:150)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.op$proxy2$1(ReifyQuotes.scala:396)
	at dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:398)
	at dotty.tools.dotc.transform.ReifyQuotes$$anon$1.transform(ReifyQuotes.scala:92)
	at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:21)
	at dotty.tools.dotc.transform.ReifyQuotes.run(ReifyQuotes.scala:88)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:296)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:297)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:180)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.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:190)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:198)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:64)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:205)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:147)
	at dotty.tools.repl.ReplCompiler.runCompilationUnit(ReplCompiler.scala:151)
	at dotty.tools.repl.ReplCompiler.compile(ReplCompiler.scala:161)
	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:233)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:196)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:129)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:132)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:151)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:132)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)
@nicolasstucki
Copy link
Contributor

Up to date version

import scala.quoted._
import scala.deriving.Mirror
def derived[T: Type](using Quotes): Expr[Any] = {
  val ev: Expr[Mirror.Of[T]] = Expr.summon(using Type.of[Mirror.Of[T]]).get
  '{null}
}

@nicolasstucki
Copy link
Contributor

Works now and in 3.0.0

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 2, 2022
bishabosha pushed a commit to dotty-staging/dotty that referenced this issue Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants