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 {
73
73
else {
74
74
val isField = sym.owner.isClass
75
75
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.
77
81
transformSyntheticModule(tree)
78
82
else if (sym.isThreadUnsafe || ctx.settings.scalajs.value)
79
83
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 1
1
trait D {
2
2
private val x = " xxxx should appear twice"
3
- private object xxxx { Console .println(x) }
3
+ object xxxx { Console .println(x) }
4
4
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
5
10
}
6
11
7
12
trait E extends D {
8
13
def f (): Unit = {
9
14
val y = " yyyy should appear twice"
10
15
object yyyy {
11
16
val x1 = get_xxxx
17
+ val z1 = get_zzzz
12
18
Console .println(y)
13
19
}
14
20
yyyy
15
21
}
16
22
}
17
23
class C extends E {}
18
- object Go extends D {
24
+ object Test extends D {
25
+ object E
19
26
def main (args : Array [String ]): Unit = {
20
27
new C ().f()
21
28
new C ().f()
You can’t perform that action at this time.
0 commit comments