Skip to content

Commit

Permalink
Fix emission of static initialisers for Modules.
Browse files Browse the repository at this point in the history
They should not be emitted for non-static modules.
All modules look as if they were static by backend.
  • Loading branch information
DarkDimius committed Aug 13, 2015
1 parent 9eb55f1 commit 96dfb35
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/dotty/tools/backend/jvm/DottyBackendInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,16 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
* True for module classes of modules that are top-level or owned only by objects. Module classes
* for such objects will get a MODULE$ flag and a corresponding static initializer.
*/
def isStaticModuleClass: Boolean = sym.isStatic && (sym is Flags.Module)
def isStaticModuleClass: Boolean =
(sym is Flags.Module) && {
// scalac uses atPickling here
// this would not work if modules are created after pickling
// for example by specialization
val original = toDenot(sym).initial
val validity = original.validFor
val shiftedContext = ctx.withPhase(validity.phaseId)
toDenot(sym)(shiftedContext).isStatic
}

def isStaticConstructor: Boolean = isStaticMember && isClassConstructor

Expand Down

0 comments on commit 96dfb35

Please sign in to comment.