aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-08-13 11:19:19 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-08-13 11:19:33 +0200
commit96dfb35b58bb7cf59f5ef55a4c1735ec0e1f5557 (patch)
tree9e591c87b7815560ab71b53457869af81d01a01a /src/dotty/tools/backend/jvm/DottyBackendInterface.scala
parent9eb55f1bb112030fe783e42c129e02f91c0aaef5 (diff)
downloaddotty-96dfb35b58bb7cf59f5ef55a4c1735ec0e1f5557.tar.gz
dotty-96dfb35b58bb7cf59f5ef55a4c1735ec0e1f5557.tar.bz2
dotty-96dfb35b58bb7cf59f5ef55a4c1735ec0e1f5557.zip
Fix emission of static initialisers for Modules.
They should not be emitted for non-static modules. All modules look as if they were static by backend.
Diffstat (limited to 'src/dotty/tools/backend/jvm/DottyBackendInterface.scala')
-rw-r--r--src/dotty/tools/backend/jvm/DottyBackendInterface.scala11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
index e39541e6c..d0993a73b 100644
--- a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
+++ b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
@@ -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