From ce4bcb536279d97617f85da3f66b5296c6ee2b96 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Fri, 3 Aug 2012 18:28:03 +0200 Subject: SI-6175 reflect over classes with symbolic names Top-level classes with symbolic names (having binary names like $colon$colon) have previously been incorrectly treated as local classes by Scala reflection. As a result they were loaded as if they weren't pickled (i.e. as Java classes). Moreover this bug also had a more subtle, but more dangerous manifestation. If such a class has already been loaded indirectly by unpickling another class (which refers to it in its pickle) and then someone tried to load it explicitly via classToScala, then it would be loaded twice (once as a Scala artifact and once as a Java artifact). This is a short route to ambiguities and crashes. The fix first checks whether a class with a suspicious name (having dollars) can be loaded as a Scala artifact (by looking it up in a symbol table). If this fails, the class is then loaded in Java style (as it was done before). Ambiguous names that can be interpreted both ways (e.g. foo_$colon$colon) are first resolved as Scala and then as Java. This prioritization cannot lead to errors, because Scala and Java artifacts with the same name cannot coexist, therefore loading a Scala artifact won't shadow a homonymous Java artifact. --- test/files/run/t6175.scala | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/files/run/t6175.scala (limited to 'test/files') 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 -- cgit v1.2.3