diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-06-08 11:43:20 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-06-08 15:35:23 +0200 |
commit | abc1c0be79ac2fb2b0e75c87a489570a9c71aa6e (patch) | |
tree | 5d2723fa39aa8b28337b1e005ae06891667580a2 /test/files/run/reflection-constructormirror-nested-badpath.scala | |
parent | 2123201e3cbc34676d2936226539bdfa0555c275 (diff) | |
download | scala-abc1c0be79ac2fb2b0e75c87a489570a9c71aa6e.tar.gz scala-abc1c0be79ac2fb2b0e75c87a489570a9c71aa6e.tar.bz2 scala-abc1c0be79ac2fb2b0e75c87a489570a9c71aa6e.zip |
tests and fixes for the mirror API
Diffstat (limited to 'test/files/run/reflection-constructormirror-nested-badpath.scala')
-rw-r--r-- | test/files/run/reflection-constructormirror-nested-badpath.scala | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/files/run/reflection-constructormirror-nested-badpath.scala b/test/files/run/reflection-constructormirror-nested-badpath.scala new file mode 100644 index 0000000000..ece0044c61 --- /dev/null +++ b/test/files/run/reflection-constructormirror-nested-badpath.scala @@ -0,0 +1,32 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.ClassTag + +class Foo{ + import Test._ + def foo = { + val expectedType = implicitly[TypeTag[R]] + val classTag = implicitly[ClassTag[R]] + val cl = classTag.runtimeClass.getClassLoader + val cm = runtimeMirror(cl) + val constructor = expectedType.tpe.member( nme.CONSTRUCTOR ).asMethodSymbol + val sig = constructor.typeSignature + val sym = cm.classSymbol( classTag.runtimeClass ) + try { + val cls = cm.reflect( this ).reflectClass( sym ) + cls.reflectConstructor( constructor )( 5,"test" ).asInstanceOf[R] + println("this indicates a failure") + } catch { + case ex: Throwable => + println(ex.getMessage) + } + } + +} +object Test extends App{ + case class R( + sales : Int, + name : String + ) + val foo = new Foo + println( foo.foo ) +}
\ No newline at end of file |