diff options
Diffstat (limited to 'test/files/run/reflection-constructormirror-nested-good.scala')
-rw-r--r-- | test/files/run/reflection-constructormirror-nested-good.scala | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/files/run/reflection-constructormirror-nested-good.scala b/test/files/run/reflection-constructormirror-nested-good.scala new file mode 100644 index 0000000000..432e9d3707 --- /dev/null +++ b/test/files/run/reflection-constructormirror-nested-good.scala @@ -0,0 +1,26 @@ +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 ) + val cls = cm.reflectClass( sym ) + cls.reflectConstructor( constructor )( 5,"test" ).asInstanceOf[R] + } +} + +object Test extends App{ + case class R( + sales : Int, + name : String + ) + val foo = new Foo + println( foo.foo ) +}
\ No newline at end of file |