diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-01-25 09:45:51 +0300 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-01-25 09:49:14 +0300 |
commit | 6c7ceb611f574a578a67c2cd653b211e555b7898 (patch) | |
tree | 4bd02fcadb35eacb252d740acd56562259999069 /test/files/run/t7328.scala | |
parent | 6c1129bdc274eeb822a1924cb22d852ea9cd62de (diff) | |
download | scala-6c7ceb611f574a578a67c2cd653b211e555b7898.tar.gz scala-6c7ceb611f574a578a67c2cd653b211e555b7898.tar.bz2 scala-6c7ceb611f574a578a67c2cd653b211e555b7898.zip |
SI-7328 FieldMirrors now support value classes
Diffstat (limited to 'test/files/run/t7328.scala')
-rw-r--r-- | test/files/run/t7328.scala | 18 |
1 files changed, 18 insertions, 0 deletions
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 |