diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-08-05 20:02:39 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-08-06 23:09:31 +0200 |
commit | 3aa221e28c3ae0381b876448e3174f0c527e9abc (patch) | |
tree | 00567362f8608a5d62ef58881561c883c99ba445 /test/files/run/reflection-valueclasses-standard.scala | |
parent | 432d7b86cb7c46d0415b8c06bf8045e309c63f03 (diff) | |
download | scala-3aa221e28c3ae0381b876448e3174f0c527e9abc.tar.gz scala-3aa221e28c3ae0381b876448e3174f0c527e9abc.tar.bz2 scala-3aa221e28c3ae0381b876448e3174f0c527e9abc.zip |
SI-6179 mirrors now work with value classes
mirrors now carry a class tag of the receiver, so that they can detect
value classes being reflected upon and adjust accordingly (e.g. allow
Int_+ for ints, but disallow it for Integers).
Surprisingly enough derived value classes (SIP-15 guys that inherit from AnyVal)
have been working all along, so no modification were required to fix them.
Diffstat (limited to 'test/files/run/reflection-valueclasses-standard.scala')
-rw-r--r-- | test/files/run/reflection-valueclasses-standard.scala | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/files/run/reflection-valueclasses-standard.scala b/test/files/run/reflection-valueclasses-standard.scala new file mode 100644 index 0000000000..18a3d1fa04 --- /dev/null +++ b/test/files/run/reflection-valueclasses-standard.scala @@ -0,0 +1,21 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.reflect.{ClassTag, classTag} + +object Test extends App { + def test[T: ClassTag: TypeTag](x: T) = { + println(s"========${classTag[T].runtimeClass}========") + println(cm.reflect(x).reflectMethod(typeOf[T].member(newTermName("getClass")).asMethod)()) + println(cm.reflect(x).reflectMethod(typeOf[T].member(newTermName("toString")).asMethod)()) + } + + test(2.toByte) + test(2.toShort) + test(2.toInt) + test(2.toLong) + test(2.toFloat) + test(2.toDouble) + test('2') + test(true) + test(()) +}
\ No newline at end of file |