Skip to content

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

@fhackett

Description

@fhackett

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions