summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2014-01-25 09:45:51 +0300
committerEugene Burmako <xeno.by@gmail.com>2014-01-25 09:49:14 +0300
commit6c7ceb611f574a578a67c2cd653b211e555b7898 (patch)
tree4bd02fcadb35eacb252d740acd56562259999069 /test
parent6c1129bdc274eeb822a1924cb22d852ea9cd62de (diff)
downloadscala-6c7ceb611f574a578a67c2cd653b211e555b7898.tar.gz
scala-6c7ceb611f574a578a67c2cd653b211e555b7898.tar.bz2
scala-6c7ceb611f574a578a67c2cd653b211e555b7898.zip
SI-7328 FieldMirrors now support value classes
Diffstat (limited to 'test')
-rw-r--r--test/files/run/reflection-magicsymbols-invoke.check2
-rw-r--r--test/files/run/t7328.check4
-rw-r--r--test/files/run/t7328.scala18
3 files changed, 23 insertions, 1 deletions
diff --git a/test/files/run/reflection-magicsymbols-invoke.check b/test/files/run/reflection-magicsymbols-invoke.check
index 7f9767f095..43116858de 100644
--- a/test/files/run/reflection-magicsymbols-invoke.check
+++ b/test/files/run/reflection-magicsymbols-invoke.check
@@ -28,7 +28,7 @@ it's important to print the list of AnyVal's members
if some of them change (possibly, adding and/or removing magic symbols), we must update this test
constructor AnyVal: ()AnyVal
method getClass: ()Class[_ <: AnyVal]
-testing AnyVal.<init>: class scala.ScalaReflectionException: unsupported symbol constructor AnyVal when invoking constructor mirror for scala.AnyVal.<init>(): AnyVal (bound to null)
+testing AnyVal.<init>: class scala.ScalaReflectionException: unsupported symbol constructor AnyVal when invoking bytecodeless method mirror for scala.AnyVal.<init>(): AnyVal (bound to null)
testing AnyVal.getClass: class scala.ScalaReflectionException: expected a member of class Integer, you provided method scala.AnyVal.getClass
============
AnyRef
diff --git a/test/files/run/t7328.check b/test/files/run/t7328.check
new file mode 100644
index 0000000000..e386fe70d9
--- /dev/null
+++ b/test/files/run/t7328.check
@@ -0,0 +1,4 @@
+Foo
+Foo(3)
+Foo(3)
+Foo(5)
diff --git a/test/files/run/t7328.scala b/test/files/run/t7328.scala
new file mode 100644
index 0000000000..8816fa2347
--- /dev/null
+++ b/test/files/run/t7328.scala
@@ -0,0 +1,18 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
+case class Foo(x: Int) extends AnyVal
+case class Bar(foo: Foo)
+
+object Test extends App {
+ val foo = typeOf[Bar].declaration(TermName("foo")).asMethod
+ println(foo.returnType) // Foo
+
+ val bar = Bar(Foo(3))
+ println(bar.foo) // Foo(3)
+
+ val im = cm.reflect(bar)
+ println(im.reflectField(foo).get) // incorrectly gives java.lang.Integer(3) not Foo(3)
+ im.reflectField(foo).set(Foo(5)) // java.lang.IllegalArgumentException: Can not set int field Bar.foo to Foo
+ println(im.reflectMethod(foo)()) // incorrectly gives java.lang.Integer(3) not Foo(3)
+} \ No newline at end of file