You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Desugar module var and accessor in refchecks/lazyvals
Rather than leaving it until mixin.
The broader motivation is to simplify the mixin phase of the
compiler before we get rid of implementatation classes in
favour of using JDK8 default interface methods.
The current code in mixin is used for both lazy val and modules,
and puts the "slow path" code that uses the monitor into a
dedicated method (`moduleName$lzyCompute`). I tracked this
back to a3d4d17. I can't tell from that commit whether the
performance sensititivity was related to modules or lazy vals,
from the commit message I'd say the latter.
As the initialization code for a module is just a constructor call,
rather than an arbitraryly large chunk of code for a lazy initializer,
this commit opts to inline the `lzycompute` method.
During refchecks, mixin module accessors are added to classes, so
that mixed in and defined modules are translated uniformly.
Defer synthesis of the double checked locking idiom to the lazyvals
phase, which gets us a step closer to a unified translation of
modules and lazy vals.
I had to change the `atOwner` methods to to avoid using the
non-existent module class of a module accessor method as the
current owner. This fixes a latent bug. Without this change,
retypechecking of the module accessor method during erasure crashes
with an accessibility error selecting the module var.
if (slowPathDef !=EmptyTree) Block(slowPathDef, ddef1) else ddef1
118
+
if (slowPathDef !=EmptyTree) {
119
+
// The contents of this block are flattened into the enclosing statement sequence, see flattenThickets
120
+
// This is a poor man's version of dotty's Thicket: https://github.com/lampepfl/dotty/blob/d5280358d1/src/dotty/tools/dotc/ast/Trees.scala#L707
currentOwner.primaryConstructor makeNotPrivate NoSymbol// SI-6601, must be done *after* pickler!
1658
-
if (bridges.nonEmpty) deriveTemplate(tree)(_ ::: bridges) else tree
1674
+
if (bridges.nonEmpty|| moduleDesugared.nonEmpty) deriveTemplate(tree)(_ ::: bridges::: moduleDesugared) else tree
1659
1675
1660
1676
case dc@TypeTreeWithDeferredRefCheck() => abort("adapt should have turned dc: TypeTreeWithDeferredRefCheck into tpt: TypeTree, with tpt.original == dc")
0 commit comments