Skip to content

Commit 7a0a826

Browse files
Clean up code to get defs to inline
1 parent f0b1a6e commit 7a0a826

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ object Inlines:
4545
else
4646
EmptyTree
4747

48+
def defsToInline(traitSym: SymDenotation)(using Context): List[Tree] =
49+
bodyToInline(traitSym) match
50+
case Block(defs, _) if traitSym.isInlineTrait => defs
51+
case _ => Nil
52+
4853
/** Are we in an inline method body? */
4954
def inInlineMethod(using Context): Boolean =
5055
ctx.owner.ownersIterator.exists(_.isInlineMethod)
@@ -474,10 +479,9 @@ object Inlines:
474479
private val thisInlineTrait = ThisType.raw(TypeRef(ctx.owner.prefix, ctx.owner))
475480

476481
def expandDefs(): List[Tree] =
477-
val tpd.Block(stats, _) = Inlines.bodyToInline(parentSym): @unchecked
478-
val stats1 = stats.filterNot(isStatAlreadyOverridden)
479-
val inlinedSymbols = stats1.map(stat => inlinedMember(stat.symbol))
480-
stats1.zip(inlinedSymbols).map(expandStat)
482+
val stats = Inlines.defsToInline(parentSym).filterNot(isStatAlreadyOverridden)
483+
val inlinedSymbols = stats.map(stat => inlinedMember(stat.symbol))
484+
stats.zip(inlinedSymbols).map(expandStat)
481485
end expandDefs
482486

483487
protected class InlineTraitTypeMap extends InlinerTypeMap {

0 commit comments

Comments
 (0)