diff options
-rw-r--r-- | src/reflect/scala/reflect/runtime/JavaMirrors.scala | 11 | ||||
-rw-r--r-- | test/files/run/t6175.scala | 5 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 64c47a5502..5eb7770de6 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -777,7 +777,16 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym lookupClass else if (jclazz.isLocalClass0 || isInvalidClassName(jname)) // local classes and implementation classes not preserved by unpickling - treat as Java - jclassAsScala(jclazz) + // + // upd. but only if they cannot be loaded as top-level classes + // otherwise we may mistake mangled symbolic names for mangled nested names + // + // in case when a Java binary name can be treated both as a top-level class and as a nested class + // (as described in http://groups.google.com/group/scala-internals/browse_thread/thread/10855403bbf04298) + // we check for a top-level class first + // this is totally correct, because a top-level class and a nested class with the same name cannot coexist + // so it's either one or another, but not both - therefore we always load $-bearing classes correctly + lookupClass orElse jclassAsScala(jclazz) else if (jclazz.isArray) ArrayClass else diff --git a/test/files/run/t6175.scala b/test/files/run/t6175.scala new file mode 100644 index 0000000000..69a0a712b6 --- /dev/null +++ b/test/files/run/t6175.scala @@ -0,0 +1,5 @@ +object Test extends App { + import reflect.runtime._ + val m = universe.typeOf[List[_]].members.head.asMethod + currentMirror.reflect (List (2, 3, 1)).reflectMethod(m) +}
\ No newline at end of file |