summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala19
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala12
2 files changed, 26 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 10879e663e..56e3dc2d5d 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -217,7 +217,9 @@ abstract class ClassfileParser {
val index = in.getChar(start + 1)
val name = getExternalName(in.getChar(starts(index) + 1))
//assert(name.endsWith("$"), "Not a module class: " + name)
- f = definitions.getModule(name.subName(0, name.length - 1))
+ f = forceMangledName(name.subName(0, name.length - 1), true)
+ if (f == NoSymbol)
+ f = definitions.getModule(name.subName(0, name.length - 1))
} else {
val origName = nme.originalName(name)
val owner = if (static) ownerTpe.typeSymbol.linkedClassOfClass else ownerTpe.typeSymbol
@@ -351,6 +353,21 @@ abstract class ClassfileParser {
throw new RuntimeException("bad constant pool tag " + in.buf(start) + " at byte " + start)
}
+ /** Try to force the chain of enclosing classes for the given name. Otherwise
+ * flatten would not lift classes that were not referenced in the source code.
+ */
+ def forceMangledName(name: Name, module: Boolean): Symbol = {
+ val parts = name.toString.split(Array('.', '$'))
+ var sym: Symbol = definitions.RootClass
+ atPhase(currentRun.flattenPhase.prev) {
+ for (part <- parts) {
+ sym = sym.info.decl(part)//.suchThat(module == _.isModule)
+ }
+ }
+// println("found: " + sym)
+ sym
+ }
+
/** Return the class symbol of the given name. */
def classNameToSymbol(name: Name): Symbol = {
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
index 2358d68575..64e8ccc0ee 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
@@ -193,11 +193,15 @@ abstract class ICodeReader extends ClassfileParser {
log("forcing " + iface.owner + " at phase: " + phase + " impl: " + iface.implClass)
iface.owner.info // force the mixin type-transformer
definitions.getClass(name)
- } else if (name.endsWith("$"))
- definitions.getModule(name.subName(0, name.length - 1))
- else
+ } else if (name.endsWith("$")) {
+ val sym = forceMangledName(name.subName(0, name.length -1), true)
+ if (sym == NoSymbol)
+ definitions.getModule(name.subName(0, name.length - 1))
+ else sym
+ } else {
+ forceMangledName(name, false)
definitions.getClass(name)
- //super.classNameToSymbol(name)
+ }
if (sym.isModule)
sym.moduleClass
else