File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,11 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
7373 else {
7474 val isField = sym.owner.isClass
7575 if (isField)
76- if (sym.isAllOf(SyntheticModule ))
76+ if sym.isAllOf(SyntheticModule ) && sym.allOverriddenSymbols.isEmpty then
77+ // I am not sure what the conditions for this optimization should be.
78+ // It was applied for all synthetic objects, but this is clearly false, as t704 demonstrates.
79+ // It seems we have to at least exclude synthetic objects that derive from mixins.
80+ // This is done by demanding that the object does not override anything.
7781 transformSyntheticModule(tree)
7882 else if (sym.isThreadUnsafe || ctx.settings.scalajs.value)
7983 if (sym.is(Module ) && ! ctx.settings.scalajs.value) {
Original file line number Diff line number Diff line change 1+ xxxx should appear twice
2+ zzzz should appear twice
3+ yyyy should appear twice
4+ xxxx should appear twice
5+ zzzz should appear twice
6+ yyyy should appear twice
Original file line number Diff line number Diff line change 11trait D {
22 private val x = " xxxx should appear twice"
3- private object xxxx { Console .println(x) }
3+ object xxxx { Console .println(x) }
44 def get_xxxx : AnyRef = xxxx
5+
6+ private val z = " zzzz should appear twice"
7+ lazy val zzzz = new ZZZZ
8+ class ZZZZ { Console .println(z) }
9+ def get_zzzz : AnyRef = zzzz
510}
611
712trait E extends D {
813 def f (): Unit = {
914 val y = " yyyy should appear twice"
1015 object yyyy {
1116 val x1 = get_xxxx
17+ val z1 = get_zzzz
1218 Console .println(y)
1319 }
1420 yyyy
1521 }
1622}
1723class C extends E {}
18- object Go extends D {
24+ object Test extends D {
25+ object E
1926 def main (args : Array [String ]): Unit = {
2027 new C ().f()
2128 new C ().f()
You can’t perform that action at this time.
0 commit comments