summaryrefslogblamecommitdiff
path: root/test/files/run/reflection-implClass.scala
blob: ed5acfc04ec60ebae06de1dcefef99ebb79e037b (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

















                                                                       
/** 
 * Tries to load a symbol for the `Foo$class` using Scala reflection.  
 * Since trait implementation classes do not get pickling information
 * symbol for them should be created using fallback mechanism
 * that exposes Java reflection information dressed up in
 * a Scala symbol.
 **/
object Test extends App {
  import scala.reflect.mirror
  val name = manifest[Foo].erasure.getName + "$class"
  val implClass = Class.forName(name)
  val symbol = mirror.classToSymbol(implClass)
  assert(symbol != mirror.NoSymbol)
}

trait Foo {
  def bar = 1
}