From d01ab1ba466c1c4778505ff4aa1747dde7309052 Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Thu, 10 Nov 2011 23:57:01 +0000 Subject: Allow to load $class classes using Scala reflec... Allow to load $class classes using Scala reflection. Tweaked implementation of invalidClassName method to exclude *$class clasess from the set of invalid names. It's not exactly clear what was the intent of this method in first place so I'm not sure if it's the best way to fix SI-5176. Added test-case that covers this issue. Fixes SI-5176. Review by odersky. --- test/files/run/reflection-implClass.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/files/run/reflection-implClass.scala (limited to 'test/files/run') diff --git a/test/files/run/reflection-implClass.scala b/test/files/run/reflection-implClass.scala new file mode 100644 index 0000000000..ed5acfc04e --- /dev/null +++ b/test/files/run/reflection-implClass.scala @@ -0,0 +1,18 @@ +/** + * 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 { + import scala.reflect.mirror + val name = manifest[Foo].erasure.getName + "$class" + val implClass = Class.forName(name) + val symbol = mirror.classToSymbol(implClass) + assert(symbol != mirror.NoSymbol) +} + +trait Foo { + def bar = 1 +} -- cgit v1.2.3