diff options
author | Aleksandar Prokopec <axel22@gmail.com> | 2012-08-17 10:55:14 +0200 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-08-17 06:40:01 -0700 |
commit | faa114e2fb6003031efa2cdd56a32a3c44aa71fb (patch) | |
tree | 7af367d2bc0c484eaf09ea8e79bd61551669122d /src/compiler | |
parent | 5a8dfad583b825158cf0abdae5d73a4a7f8cd997 (diff) | |
download | scala-faa114e2fb6003031efa2cdd56a32a3c44aa71fb.tar.gz scala-faa114e2fb6003031efa2cdd56a32a3c44aa71fb.tar.bz2 scala-faa114e2fb6003031efa2cdd56a32a3c44aa71fb.zip |
Fixes SI-6236.
In separate compilation runs, the static field symbol in the
companion class of an object was not being recreated.
Given that the singleton object was compiled separately,
the static field symbol will be recreated on demand.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/GenICode.scala | 15 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/CleanUp.scala | 2 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 1b89aa5560..a40d8c1a06 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -890,8 +890,19 @@ abstract class GenICode extends SubComponent { generatedType = toTypeKind(sym.accessed.info) val hostOwner = qual.tpe.typeSymbol.orElse(sym.owner) val hostClass = hostOwner.companionClass - val staticfield = hostClass.info.findMember(sym.accessed.name, NoFlags, NoFlags, false) - + val staticfield = hostClass.info.findMember(sym.accessed.name, NoFlags, NoFlags, false) orElse { + if (!currentRun.compiles(hostOwner)) { + // hostOwner was separately compiled -- the static field symbol needs to be recreated in hostClass + import Flags._ + debuglog("recreating sym.accessed.name: " + sym.accessed.name) + val objectfield = hostOwner.info.findMember(sym.accessed.name, NoFlags, NoFlags, false) + val staticfield = hostClass.newVariable(newTermName(sym.accessed.name.toString), tree.pos, STATIC | SYNTHETIC | FINAL) setInfo objectfield.tpe + staticfield.addAnnotation(definitions.StaticClass) + hostClass.info.decls enter staticfield + staticfield + } else NoSymbol + } + if (sym.isGetter) { ctx.bb.emit(LOAD_FIELD(staticfield, true) setHostClass hostClass, tree.pos) ctx diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 4258ee8a88..6f402e9cd1 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -586,7 +586,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { // create a static field in the companion class for this @static field val stfieldSym = linkedClass.newVariable(newTermName(name), tree.pos, STATIC | SYNTHETIC | FINAL) setInfo sym.tpe stfieldSym.addAnnotation(StaticClass) - + val names = classNames.getOrElseUpdate(linkedClass, linkedClass.info.decls.collect { case sym if sym.name.isTermName => sym.name } toSet) |