@@ -622,8 +622,8 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
622
622
def isSynchronized : Boolean = sym is Flags .Synchronized
623
623
def isNonBottomSubClass (other : Symbol ): Boolean = sym.derivesFrom(other)
624
624
def hasAnnotation (ann : Symbol ): Boolean = toDenot(sym).hasAnnotation(ann)
625
- def shouldEmitForwarders : Boolean = // exitingPickler { !(sym.name.toString contains '$')
626
- (sym is Flags .Module ) && ! (sym is Flags .ImplClass ) // / ! sym.isNestedClass
625
+ def shouldEmitForwarders : Boolean =
626
+ (sym is Flags .Module ) && ! (sym is Flags .ImplClass ) && sym.isStatic
627
627
def isJavaEntryPoint : Boolean = CollectEntryPoints .isJavaEntryPoint(sym)
628
628
629
629
def isClassConstructor : Boolean = toDenot(sym).isClassConstructor
@@ -632,7 +632,16 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
632
632
* True for module classes of modules that are top-level or owned only by objects. Module classes
633
633
* for such objects will get a MODULE$ flag and a corresponding static initializer.
634
634
*/
635
- def isStaticModuleClass : Boolean = sym.isStatic && (sym is Flags .Module )
635
+ def isStaticModuleClass : Boolean =
636
+ (sym is Flags .Module ) && {
637
+ // scalac uses atPickling here
638
+ // this would not work if modules are created after pickling
639
+ // for example by specialization
640
+ val original = toDenot(sym).initial
641
+ val validity = original.validFor
642
+ val shiftedContext = ctx.withPhase(validity.phaseId)
643
+ toDenot(sym)(shiftedContext).isStatic
644
+ }
636
645
637
646
def isStaticConstructor : Boolean = isStaticMember && isClassConstructor
638
647
0 commit comments