Skip to content

('{None}).show crashes when called indirectly from REPL #6092

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
fhackett opened this issue Mar 14, 2019 · 2 comments
Closed

('{None}).show crashes when called indirectly from REPL #6092

fhackett opened this issue Mar 14, 2019 · 2 comments
Assignees

Comments

@fhackett
Copy link
Contributor

This error is a little weird to reproduce. First, make a file like this:

package testthething

import quoted._

object Main {
  def main(argv : Array[String]) : Unit = {
    import quoted.Toolbox.Default._
    println(('{None}).show)
  }
}

If you compile this file using dotc then run it using dotr -with-compiler testthething.Main everything is fine. If however you open a REPL using dotr -with-compiler then try to call the same method explicitly as in testthething.Main.main(Array()) it crashes spectacularly:

scala> testthething.Main.main(Array())
Bad symbolic reference. A signature
refers to testthething[ModuleClass]/T in package <root> which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling the signature.
java.lang.Exception: Could not extract Expr(<pickled tasty>)
        at dotty.tools.dotc.quoted.QuoteDriver.withTree$$anonfun$2(QuoteDriver.scala:65)
        at scala.Option.getOrElse(Option.scala:138)
        at dotty.tools.dotc.quoted.QuoteDriver.withTree(QuoteDriver.scala:65)
        at dotty.tools.dotc.quoted.QuoteDriver.show(QuoteDriver.scala:53)
        at dotty.tools.dotc.quoted.ToolboxImpl$$anon$1.show(ToolboxImpl.scala:25)
        at scala.quoted.Expr.show(Expr.scala:16)
        at testthething.Main$.main(Test.scala:8)
        at rs$line$1$.<init>(rs$line$1:1)
[abridged]

This seems related somehow to the T in Option[T]. The same code with, say, Unit does not crash in the same way.
Pasting the same code into the REPL directly (minus the package declaration) also runs fine.
Removing the package declaration from the file then running Main.main also prevents the problem from occurring.

@nicolasstucki
Copy link
Contributor

The pickled tree of '{None} contains testthething inside the call of an Inlined node. Is that particular case we are probably missing testthething.Main in the classpath. This may be related to #6007.

@nicolasstucki
Copy link
Contributor

Now that the application needs to provide the classloader explicitly this issue is fixed.

The code needs to use scala.quoted.Toolbox.make(getClass.getClassLoader):

package testthething

import quoted._

object Main {
  def main(argv : Array[String]) : Unit = {
    implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
    println(('{None}).show)
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants