Skip to content

Commit 5fa112a

Browse files
Compute overriden symbols only once
1 parent 55b6c8b commit 5fa112a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

compiler/src/dotty/tools/dotc/inlines/Inlines.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ object Inlines:
170170
tree2
171171
end inlineCall
172172

173-
def inlineParentTrait(parent: tpd.Tree, childOverrideDecls: Set[Symbol])(using Context): List[Tree] =
173+
def inlineParentTrait(parent: tpd.Tree, overriddenDecls: Set[Symbol])(using Context): List[Tree] =
174174
val traitSym = if parent.symbol.isConstructor then parent.symbol.owner else parent.symbol
175-
if traitSym.isInlineTrait then InlineParentTrait(parent, traitSym.asClass, childOverrideDecls).expandDefs()
175+
if traitSym.isInlineTrait then InlineParentTrait(parent, traitSym.asClass, overriddenDecls).expandDefs()
176176
else Nil
177177

178178
/** Try to inline a pattern with an inline unapply method. Fail with error if the maximal
@@ -503,7 +503,7 @@ object Inlines:
503503
allParams(info).flatten.zip(allArgs(parent).reverse.flatten).toMap
504504

505505
private def isStatAlreadyOverridden(stat: Tree): Boolean =
506-
overriddenDecls.flatMap(_.allOverriddenSymbols).toSet.contains(stat.symbol)
506+
overriddenDecls.contains(stat.symbol)
507507

508508
private def expandStat(stat: tpd.Tree, inlinedSym: Symbol): tpd.Tree = stat match
509509
case stat: ValDef if stat.symbol.is(ParamAccessor) =>

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,8 +2657,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
26572657
if ctx.isAfterTyper then
26582658
Nil
26592659
else
2660-
val clsDecls = cls.info.decls.toList.toSet
2661-
parents1.flatMap(parent => Inlines.inlineParentTrait(parent, clsDecls))
2660+
val overriddenSyms = cls.info.decls.toList.flatMap(_.allOverriddenSymbols).toSet
2661+
parents1.flatMap(parent => Inlines.inlineParentTrait(parent, overriddenSyms))
26622662
val body1 = addAccessorDefs(cls, typedStats(impl.body, dummy)(using ctx.inClassContext(self1.symbol))._1) ::: inlineTraitDefs
26632663

26642664
if !ctx.isAfterTyper && cls.isInlineTrait then

0 commit comments

Comments
 (0)