From 0f0144c74088e396fc1440166bed5a7c6d5f44f4 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 23 Apr 2012 16:04:56 +0200 Subject: migrates stdlib and compiler to tags * all usages of ClassManifest and Manifest are replaced with tags * all manifest tests are replaced with tag tests --- test/files/run/reflection-implClass-new.scala | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 test/files/run/reflection-implClass-new.scala (limited to 'test/files/run/reflection-implClass-new.scala') diff --git a/test/files/run/reflection-implClass-new.scala b/test/files/run/reflection-implClass-new.scala new file mode 100644 index 0000000000..27374f2106 --- /dev/null +++ b/test/files/run/reflection-implClass-new.scala @@ -0,0 +1,38 @@ +/** + * Tries to load a symbol for the `Foo$class` using Scala reflection. + * Since trait implementation classes do not get pickling information + * symbol for them should be created using fallback mechanism + * that exposes Java reflection information dressed up in + * a Scala symbol. + */ +object Test extends App with Outer { + import scala.reflect.mirror + + assert(mirror.classToSymbol(classTag[Foo].erasure).typeSignature.declaration(mirror.newTermName("bar")).typeSignature == + mirror.classToSymbol(classTag[Bar].erasure).typeSignature.declaration(mirror.newTermName("foo")).typeSignature) + + val s1 = implClass(classTag[Foo].erasure) + assert(s1 != mirror.NoSymbol) + assert(s1.typeSignature != mirror.NoType) + assert(s1.companionSymbol.typeSignature != mirror.NoType) + assert(s1.companionSymbol.typeSignature.declaration(mirror.newTermName("bar")) != mirror.NoSymbol) + val s2 = implClass(classTag[Bar].erasure) + assert(s2 != mirror.NoSymbol) + assert(s2.typeSignature != mirror.NoType) + assert(s2.companionSymbol.typeSignature != mirror.NoType) + assert(s2.companionSymbol.typeSignature.declaration(mirror.newTermName("foo")) != mirror.NoSymbol) + def implClass(clazz: Class[_]) = { + val implClass = Class.forName(clazz.getName + "$class") + mirror.classToSymbol(implClass) + } +} + +trait Foo { + def bar = 1 +} + +trait Outer { + trait Bar { + def foo = 1 + } +} -- cgit v1.2.3