summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/reflection-allmirrors-tostring.check14
-rw-r--r--test/files/run/reflection-allmirrors-tostring.scala43
2 files changed, 57 insertions, 0 deletions
diff --git a/test/files/run/reflection-allmirrors-tostring.check b/test/files/run/reflection-allmirrors-tostring.check
new file mode 100644
index 0000000000..b5fe6c33bb
--- /dev/null
+++ b/test/files/run/reflection-allmirrors-tostring.check
@@ -0,0 +1,14 @@
+class mirror for C (bound to null)
+module mirror for M (bound to null)
+instance mirror for an instance of C
+field mirror for C.f1 (bound to an instance of C)
+field mirror for C.f2 (bound to an instance of C)
+method mirror for C.m1: Int (bound to an instance of C)
+method mirror for C.m2(): Int (bound to an instance of C)
+method mirror for C.m3[T >: String <: Int]: T (bound to an instance of C)
+method mirror for C.m4[A, B <: A[Int]](x: A[B])(implicit y: Int): Nothing (bound to an instance of C)
+method mirror for C.m5(x: => Int, y: Int*): String (bound to an instance of C)
+class mirror for C.C (bound to an instance of C)
+module mirror for C.M (bound to an instance of C)
+constructor mirror for C.<init>(): C (bound to null)
+constructor mirror for C.C.<init>(): C.this.C (bound to an instance of C)
diff --git a/test/files/run/reflection-allmirrors-tostring.scala b/test/files/run/reflection-allmirrors-tostring.scala
new file mode 100644
index 0000000000..73afff291c
--- /dev/null
+++ b/test/files/run/reflection-allmirrors-tostring.scala
@@ -0,0 +1,43 @@
+import scala.reflect.runtime.universe._
+
+class C {
+ val f1 = 2
+ var f2 = 3
+
+ def m1 = 4
+ def m2() = 5
+ def m3[T >: String <: Int]: T = ???
+ def m4[A[_], B <: A[Int]](x: A[B])(implicit y: Int) = ???
+ def m5(x: => Int, y: Int*): String = ???
+
+ class C
+ object M
+
+ override def toString = "an instance of C"
+}
+object M
+
+object Test extends App {
+ val cm = scala.reflect.runtime.currentMirror
+// println(cm)
+
+ println(cm.reflectClass(cm.staticClass("C")))
+ println(cm.reflectModule(cm.staticModule("M")))
+ println(cm.reflect(new C))
+
+ val im = cm.reflect(new C)
+ println(im.reflectField(typeOf[C].member(newTermName("f1")).asTerm))
+ println(im.reflectField(typeOf[C].member(newTermName("f2")).asTerm))
+ println(im.reflectMethod(typeOf[C].member(newTermName("m1")).asMethod))
+ println(im.reflectMethod(typeOf[C].member(newTermName("m2")).asMethod))
+ println(im.reflectMethod(typeOf[C].member(newTermName("m3")).asMethod))
+ println(im.reflectMethod(typeOf[C].member(newTermName("m4")).asMethod))
+ println(im.reflectMethod(typeOf[C].member(newTermName("m5")).asMethod))
+ println(im.reflectClass(typeOf[C].member(newTypeName("C")).asClass))
+ println(im.reflectModule(typeOf[C].member(newTermName("M")).asModule))
+
+ val c = cm.staticClass("C")
+ val cc = typeOf[C].member(newTypeName("C")).asClass
+ println(cm.reflectClass(c).reflectConstructor(c.typeSignature.member(nme.CONSTRUCTOR).asMethod))
+ println(im.reflectClass(cc).reflectConstructor(cc.typeSignature.member(nme.CONSTRUCTOR).asMethod))
+} \ No newline at end of file