Question

I am trying to invoke the method typeOfInstance() in the following (simplest) code:

import scala.reflect.mirror._

class Bar

object Main extends App {
  val bar = new Bar()
  typeOfInstance(bar)
}

but I am receiving an AssertionError while executing it:

java.lang.AssertionError: assertion failed: no symbol could be loaded from package annotation (scala equivalent is class com.hablapps.annotation.Bar) by name Bar

The above code runs fine in the REPL (with :power mode). The problem arises while running from SBT (with Scala 2.10-M3 set). Does anybody know what could be happening?

Was it helpful?

Solution

This is a known issue with M3.

In that preview version of Scala, reflection only works with straightforward classloading schemes (e.g. when you run your application using good old java -cp <classpath> <name of the main class>). SBT is a bit more involved, and things blow up.

We've fixed this in 2.10.0-M4.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top