Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to emission of static initializers and forwarders in backend. #754

Merged
merged 2 commits into from
Aug 13, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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