summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2011-11-10 23:57:01 +0000
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2011-11-10 23:57:01 +0000
commitd01ab1ba466c1c4778505ff4aa1747dde7309052 (patch)
treec0938296043d800871826ca6844748d9a52f289f /test/files/run
parent10f7a8c465a71d29c36884ff85f371ea8e364023 (diff)
downloadscala-d01ab1ba466c1c4778505ff4aa1747dde7309052.tar.gz
scala-d01ab1ba466c1c4778505ff4aa1747dde7309052.tar.bz2
scala-d01ab1ba466c1c4778505ff4aa1747dde7309052.zip
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.
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/reflection-implClass.scala18
1 files changed, 18 insertions, 0 deletions
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
+}