summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/reflect/runtime/Loaders.scala5
-rw-r--r--test/files/run/reflection-implClass.scala18
2 files changed, 22 insertions, 1 deletions
diff --git a/src/compiler/scala/reflect/runtime/Loaders.scala b/src/compiler/scala/reflect/runtime/Loaders.scala
index 46ee176b0f..ad6bf34591 100644
--- a/src/compiler/scala/reflect/runtime/Loaders.scala
+++ b/src/compiler/scala/reflect/runtime/Loaders.scala
@@ -90,7 +90,10 @@ trait Loaders { self: SymbolTable =>
def invalidClassName(name: Name) = {
val dp = name pos '$'
- 0 < dp && dp < (name.length - 1)
+ //it's not clear what's the definition of an invalid class name but
+ //implementation class is certainly a valid class that we would
+ //like to load (grek)
+ 0 < dp && dp < (name.length - 1) && !nme.isImplClassName(name)
}
class PackageScope(pkgClass: Symbol) extends Scope {
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
+}