This question answers:
import scala.reflect.runtime.universe._ trait B trait C class A extends B with C val tpe = typeOf[A] tpe.baseClasses foreach {s => println(s.fullName)}
It works in REPL, but when I injected the code into a Scala script file and executed it, it no longer ran:
typeOf[A] // Compiler error: No TypeTag available for this.A
Using weakTypeTag instead did not help either
weakTypeTag[A] // Runtime error: scala.reflect.internal.FatalError: // ThisType(free type $anon) for sym which is not a class
I got the same behavior with Scala 2.10.0, 2.10.1 and 2.11.0-M2.
source share