Skip to content

Commit

Permalink
Merge pull request #754 from dotty-staging/fix-objects
Browse files Browse the repository at this point in the history
Fixes to emission of static initializers and forwarders in backend.
  • Loading branch information
DarkDimius committed Aug 13, 2015
2 parents 9eb55f1 + 945fefb commit f5a94f7
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/dotty/tools/backend/jvm/DottyBackendInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,8 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
def isSynchronized: Boolean = sym is Flags.Synchronized
def isNonBottomSubClass(other: Symbol): Boolean = sym.derivesFrom(other)
def hasAnnotation(ann: Symbol): Boolean = toDenot(sym).hasAnnotation(ann)
def shouldEmitForwarders: Boolean = //exitingPickler { !(sym.name.toString contains '$')
(sym is Flags.Module) && !(sym is Flags.ImplClass) /// !sym.isNestedClass
def shouldEmitForwarders: Boolean =
(sym is Flags.Module) && !(sym is Flags.ImplClass) && sym.isStatic
def isJavaEntryPoint: Boolean = CollectEntryPoints.isJavaEntryPoint(sym)

def isClassConstructor: Boolean = toDenot(sym).isClassConstructor
Expand All @@ -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 f5a94f7

Please sign in to comment.