Skip to content

Commit a754f24

Browse files
committed
Do a bit less work in Mixin.transformSym.
* Avoid transforming members of Java interfaces. * Avoid cloning a scope if we do not need it.
1 parent 64d3b9a commit a754f24

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/src/dotty/tools/dotc/transform/Mixin.scala

+5-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class Mixin extends MiniPhase with SymTransformer { thisPhase =>
122122
override def changesMembers: Boolean = true // the phase adds implementions of mixin accessors
123123

124124
override def transformSym(sym: SymDenotation)(using Context): SymDenotation =
125-
def ownerIsTrait: Boolean = wasOneOf(sym.owner, Trait)
125+
def ownerIsTrait: Boolean = was(sym.owner, Trait, butNot = JavaDefined)
126126

127127
if (sym.is(Accessor, butNot = Deferred) && ownerIsTrait) {
128128
val sym1 =
@@ -140,7 +140,7 @@ class Mixin extends MiniPhase with SymTransformer { thisPhase =>
140140
info = MethodType(Nil, sym.info.resultType))
141141
else if sym.is(Trait, butNot = JavaDefined) then
142142
val classInfo = sym.asClass.classInfo
143-
val decls1 = classInfo.decls.cloneScope
143+
lazy val decls1 = classInfo.decls.cloneScope
144144
var modified: Boolean = false
145145
for (decl <- classInfo.decls)
146146
// !decl.isClass avoids forcing nested traits, preventing cycles
@@ -160,6 +160,9 @@ class Mixin extends MiniPhase with SymTransformer { thisPhase =>
160160
private def wasOneOf(sym: Symbol, flags: FlagSet)(using Context): Boolean =
161161
atPhase(thisPhase) { sym.isOneOf(flags) }
162162

163+
private def was(sym: Symbol, flag: Flag, butNot: FlagSet)(using Context): Boolean =
164+
atPhase(thisPhase) { sym.is(flag, butNot) }
165+
163166
private def needsTraitSetter(sym: Symbol)(using Context): Boolean =
164167
sym.isGetter && !wasOneOf(sym, DeferredOrLazy | ParamAccessor)
165168
&& atPhase(thisPhase) { !sym.setter.exists }

0 commit comments

Comments
 (0)