@@ -9,7 +9,7 @@ import dotty.tools.dotc.core.Contexts.Context
9
9
import dotty .tools .dotc .core .Decorators ._
10
10
import dotty .tools .dotc .core .DenotTransformers .IdentityDenotTransformer
11
11
import dotty .tools .dotc .core .Flags ._
12
- import dotty .tools .dotc .core .NameKinds .{LazyBitMapName , LazyLocalInitName , LazyLocalName }
12
+ import dotty .tools .dotc .core .NameKinds .{LazyBitMapName , LazyLocalInitName , LazyLocalName , ExpandedName }
13
13
import dotty .tools .dotc .core .StdNames .nme
14
14
import dotty .tools .dotc .core .Symbols ._
15
15
import dotty .tools .dotc .core .Types ._
@@ -73,11 +73,18 @@ 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 ) && sym.allOverriddenSymbols.isEmpty then
76
+ if sym.isAllOf(SyntheticModule )
77
+ && sym.allOverriddenSymbols.isEmpty
78
+ && ! sym.name.is(ExpandedName ) then
77
79
// I am not sure what the conditions for this optimization should be.
78
80
// It was applied for all synthetic objects, but this is clearly false, as t704 demonstrates.
79
81
// It seems we have to at least exclude synthetic objects that derive from mixins.
80
82
// This is done by demanding that the object does not override anything.
83
+ // Figuring out whether a symbol implements a trait module is not so simple.
84
+ // For non-private trait members we can check whether there is an overridden symbol.
85
+ // For private trait members this does not work, since `ensureNotPrivate` in phase Mixins
86
+ // does change the name but does not update the owner's scope, so `allOverriddenSymbols` does
87
+ // not work in that case. However, we can check whether the name is an ExpandedName instead.
81
88
transformSyntheticModule(tree)
82
89
else if (sym.isThreadUnsafe || ctx.settings.scalajs.value)
83
90
if (sym.is(Module ) && ! ctx.settings.scalajs.value) {
0 commit comments