Skip to content

Assertion failed: unresolved symbols when pickling UnApply in quoted code #11211

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
justinhj opened this issue Jan 25, 2021 · 1 comment · Fixed by #11301
Closed

Assertion failed: unresolved symbols when pickling UnApply in quoted code #11211

justinhj opened this issue Jan 25, 2021 · 1 comment · Fixed by #11301
Assignees
Milestone

Comments

@justinhj
Copy link

justinhj commented Jan 25, 2021

Compiler version

Not sure where scalac is running from. I have a build.sbt project with version 3.0.0-M3

Minimized code

import scala.quoted._

def takeOptionImpl[T](o: Expr[Option[T]], default: Expr[T])(using Quotes, Type[T]): Expr[T] = '{
 $o match {
   case Some(t1) => t1
   case None: Option[T] => $default
 }
}

inline def takeOption[T](inline o: Option[T], inline default: T) = ${takeOptionImpl('o, 'default)}
  
// In another file 

println(s"takeOption ${MapNMacro.takeOption(Option(15), 10)}")

Output (click arrow to expand)

scalac: Error: assertion failed: unresolved symbols: [33mtype[0m [35mT[0m (line 11) #5806 when pickling /Users/justinhj/evalexample/src/main/scala/MapNMacro.scala
java.lang.AssertionError: assertion failed: unresolved symbols: [33mtype[0m [35mT[0m (line 11) #5806 when pickling /Users/justinhj/evalexample/src/main/scala/MapNMacro.scala
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:778)
	at dotty.tools.dotc.quoted.PickledQuotes$.pickle(PickledQuotes.scala:166)
	at dotty.tools.dotc.quoted.PickledQuotes$.pickleQuote(PickledQuotes.scala:37)
	at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.pickleAsTasty$1(PickleQuotes.scala:222)
	at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.pickledQuote(PickleQuotes.scala:305)
	at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transformQuotation(PickleQuotes.scala:142)
	at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:114)
	at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:514)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1287)
	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.transform(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:514)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1293)
	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.transform(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:514)
	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.transform(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:514)
	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.transform(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:514)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1370)
	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.transform(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:514)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$2(Trees.scala:1394)
	at scala.collection.immutable.List.mapConserve(List.scala:472)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1394)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1392)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1379)
	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.transform(TreeMapWithStages.scala:148)
	at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:514)
	at dotty.tools.dotc.transform.PickleQuotes$$anon$1.transform(PickleQuotes.scala:95)
	at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:21)
	at dotty.tools.dotc.transform.PickleQuotes.run(PickleQuotes.scala:91)
	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: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.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:210)
	at dotty.tools.dotc.Run.compileSources(Run.scala:146)
	at dotty.tools.dotc.Run.compile(Run.scala:130)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
	at dotty.tools.dotc.Driver.process(Driver.scala:186)
	at dotty.tools.dotc.Main.process(Main.scala)
	at xsbt.CachedCompilerImpl.run(CachedCompilerImpl.java:69)
	at xsbt.CompilerInterface.run(CompilerInterface.java:41)
	at jdk.internal.reflect.GeneratedMethodAccessor174.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at sbt.internal.inc.AnalyzingCompiler.invoke(AnalyzingCompiler.scala:315)
	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:110)
	at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:57)
	at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:43)
	at org.jetbrains.jps.incremental.scala.remote.Main$.compileLogic(Main.scala:158)
	at org.jetbrains.jps.incremental.scala.remote.Main$.$anonfun$handleCommand$1(Main.scala:141)
	at org.jetbrains.jps.incremental.scala.remote.Main$.decorated$1(Main.scala:131)
	at org.jetbrains.jps.incremental.scala.remote.Main$.handleCommand(Main.scala:138)
	at org.jetbrains.jps.incremental.scala.remote.Main$.serverLogic(Main.scala:115)
	at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:71)
	at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
	at jdk.internal.reflect.GeneratedMethodAccessor169.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
smarter added a commit to dotty-staging/dotty that referenced this issue Jan 25, 2021
Almost no one uses `scalac` by hand, so it's not a good way to get the
current compiler version (example:
scala#11211), give the sbt command
instead.
smarter added a commit to dotty-staging/dotty that referenced this issue Jan 25, 2021
Give the sbt command for finding the current version, this avoids
confusion like in scala#11211.
@nicolasstucki nicolasstucki self-assigned this Feb 1, 2021
@nicolasstucki
Copy link
Contributor

nicolasstucki commented Feb 3, 2021

Minimized to

import scala.quoted._
def takeOptionImpl[T](using Quotes, Type[T]): Unit = '{
  (??? : Option[T]) match
    case Some(t) => ???
}

@nicolasstucki nicolasstucki changed the title Assertion failed: unresolved symbols when pickling in macro expansion Assertion failed: unresolved symbols when pickling UnApply in quoted code Feb 3, 2021
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 3, 2021
michelou pushed a commit to michelou/scala3 that referenced this issue Feb 5, 2021
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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.

3 participants