summaryrefslogtreecommitdiff
path: root/test/files/run/reify_closure8b.scala
blob: c693cb490e902f77c37b5ee8a25f4b7d1f9792f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import scala.reflect.runtime.universe._
import scala.reflect.runtime.{universe => ru}
import scala.reflect.runtime.{currentMirror => cm}
import scala.tools.reflect.ToolBox

object Test extends App {
  // will fail because y is a private field
  // reification doesn't magically make unavailable stuff available
  class Foo(y: Int) {
    def fun = reify{y}
  }

  try {
    val dyn = cm.mkToolBox().eval(new Foo(10).fun.tree)
    val foo = dyn.asInstanceOf[Int]
    println(foo)
  } catch {
    case ex: Throwable =>
      println(ex)
  }
}