diff options
author | Paul Phillips <paulp@improving.org> | 2009-02-22 15:31:08 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-02-22 15:31:08 +0000 |
commit | 502a422b3fd668a7d0c07a7b4f3c4cecdbf5b9ca (patch) | |
tree | f951ab66d293d033c51487ffafa4c73bb452288d /src | |
parent | 7e908c84ffed89bf8325eaa0dddfc449213f1c64 (diff) | |
download | scala-502a422b3fd668a7d0c07a7b4f3c4cecdbf5b9ca.tar.gz scala-502a422b3fd668a7d0c07a7b4f3c4cecdbf5b9ca.tar.bz2 scala-502a422b3fd668a7d0c07a7b4f3c4cecdbf5b9ca.zip |
Proposed fix for #1735; may need refinement, bu...
Proposed fix for #1735; may need refinement, but I think this patch is
less dangerous than the already commited patch for #363.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 6deba491f5..985af2bef6 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -205,21 +205,10 @@ abstract class GenJVM extends SubComponent { } } else { - // indiscriminate forwarding of methods causes issues with class generation, but - // we should at least forward a main method if we can -- bug #363 - val mod = c.symbol.linkedModuleOfClass - lazy val mainSym = mod.info.decls.lookup(nme.main) - - def mainForwarderNeeded() = { - mod != NoSymbol && - !c.symbol.hasFlag(Flags.INTERFACE) && - mainSym != NoSymbol && - !c.symbol.info.nonPrivateMembers.exists(_.name == nme.main) - } - - if (mainForwarderNeeded) { - log("Adding main method forwarder from " + c.symbol + " to " + mod.moduleClass) - addForwarder(jclass, mod.moduleClass, mainSym) + // add static forwarders if there are no name conflicts; see bugs #363 and #1735 + if (c.symbol.linkedModuleOfClass != NoSymbol && !c.symbol.hasFlag(Flags.INTERFACE)) { + log("Adding forwarders to existing class " + c.symbol + " found in module " + c.symbol.linkedModuleOfClass) + addForwarders(jclass, c.symbol.linkedModuleOfClass.moduleClass) } } @@ -695,14 +684,15 @@ abstract class GenJVM extends SubComponent { import JAccessFlags._ val moduleName = javaName(module) // + "$" val mirrorName = moduleName.substring(0, moduleName.length() - 1) - val paramJavaTypes = m.tpe.paramTypes map toTypeKind + val paramJavaTypes = m.info.paramTypes map toTypeKind val paramNames: Array[String] = new Array[String](paramJavaTypes.length); for (val i <- 0.until(paramJavaTypes.length)) paramNames(i) = "x_" + i + val mirrorMethod = jclass.addNewMethod(ACC_PUBLIC | ACC_FINAL | ACC_STATIC, javaName(m), - javaType(m.tpe.resultType), + javaType(m.info.resultType), javaTypes(paramJavaTypes), paramNames); val mirrorCode = mirrorMethod.getCode().asInstanceOf[JExtendedCode]; @@ -753,7 +743,7 @@ abstract class GenJVM extends SubComponent { if (settings.debug.value) log("Dumping mirror class for object: " + module); - for (m <- atPhase(currentRun.picklerPhase)(module.tpe.nonPrivateMembers); if shouldForward(m)) + for (m <- module.info.nonPrivateMembers; if shouldForward(m)) addForwarder(jclass, module, m) } |