2

The following trivial example (run in Scala 2.11.8):

import scala.tools.reflect.ToolBox
import scala.reflect.runtime.currentMirror

object Main extends App {

  val toolbox = currentMirror.mkToolBox()

  val tree = toolbox.parse {
    """
    package foo.bar {
       trait Baz
    }
    """
  }
  println(tree)

  val checkedTree = toolbox.typecheck(tree)
  println(tree)
}

results in the follow exception at the toolbox.typecheck(tree) line:

Exception in thread "main" java.lang.AssertionError: assertion failed: value <local <expression-owner>>
    at scala.reflect.internal.Symbols$Symbol.newPackage(Symbols.scala:310)
    at scala.tools.nsc.typechecker.Namers$Namer.createPackageSymbol(Namers.scala:381)
    at scala.tools.nsc.typechecker.Namers$Namer.createPackageSymbol(Namers.scala:374)
    ...

How does one get the typechecked AST tree??

Brian Kent
  • 3,754
  • 1
  • 26
  • 31

0 Answers0