-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
This REPL session show the problem:
import scala.reflect.runtime.{currentMirror => cm}
import scala.tools.reflect.ToolBox
val toolbox = cm.mkToolBox()
toolbox.parse("package Foo; class Bar")
scala.tools.reflect.ToolBoxError: reflective compilation has failed:
illegal start of definition
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.throwIfErrors(ToolBoxFactory.scala:318)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.parse(ToolBoxFactory.scala:289)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.parse(ToolBoxFactory.scala:405)
Quick glance over the code:
https://github.com/scala/scala/blob/2.10.x/src/compiler/scala/tools/reflect/ToolBoxFactory.scala#L283
makes it clear why it fails. This should be fixed either by changing wrapper to being a package instead of object or documenting it clearly. I think the former option is a winner.
Eugene, can you comment?