summaryrefslogtreecommitdiff
path: root/test/files/run/reflection-sanitychecks.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-08-06 17:55:12 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-08-06 23:09:32 +0200
commit3cbe07f3e3ddb7201d1d174399d14d4a69df52fd (patch)
treef85e48e71ee73c51ec61138a6095e0f8c4c78254 /test/files/run/reflection-sanitychecks.scala
parent3c4f4865f6420f98a7ed502257bc65387951e26c (diff)
downloadscala-3cbe07f3e3ddb7201d1d174399d14d4a69df52fd.tar.gz
scala-3cbe07f3e3ddb7201d1d174399d14d4a69df52fd.tar.bz2
scala-3cbe07f3e3ddb7201d1d174399d14d4a69df52fd.zip
sanity check for reflectConstructor
In 911bbc4 I've completely overlooked the fact that reflectConstructor exists and that is also needs sanity checks. Now reflectConstructor checks that the incoming symbol is actually a ctor, and that it is actually a ctor of the class reflected by the current mirror.
Diffstat (limited to 'test/files/run/reflection-sanitychecks.scala')
-rw-r--r--test/files/run/reflection-sanitychecks.scala4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/files/run/reflection-sanitychecks.scala b/test/files/run/reflection-sanitychecks.scala
index e95d130460..b0982fc2fc 100644
--- a/test/files/run/reflection-sanitychecks.scala
+++ b/test/files/run/reflection-sanitychecks.scala
@@ -3,6 +3,7 @@ class C {
def bar = 2
class C { override def toString = "CC" }
object O { override def toString = "CO" }
+ override def toString = "an instance of class C"
}
class D {
@@ -10,6 +11,7 @@ class D {
def bar = 4
class C { override def toString = "DC" }
object O { override def toString = "DO" }
+ override def toString = "an instance of class D"
}
object Test extends App {
@@ -21,6 +23,8 @@ object Test extends App {
def failsafe(action: => Any): Any = try action catch { case ex: Throwable => ex.toString }
println("field: " + failsafe(im.reflectField(tpe.member(newTermName("foo")).asTerm).get))
println("method: " + failsafe(im.reflectMethod(tpe.member(newTermName("bar")).asMethod)()))
+ println("constructor #1: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(newTermName("bar")).asMethod)()))
+ println("constructor #2: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(newTermName("<init>")).asMethod)()))
println("class: " + failsafe(im.reflectClass(tpe.member(newTypeName("C")).asClass).reflectConstructor(typeOf[C].member(newTypeName("C")).asClass.typeSignature.member(newTermName("<init>")).asMethod)()))
println("object: " + failsafe(im.reflectModule(tpe.member(newTermName("O")).asModule).instance))
}