@@ -550,6 +550,9 @@ object Inlines:
550
550
override protected val inlinerTypeMap : InlinerTypeMap = InlineTraitTypeMap ()
551
551
override protected val inlinerTreeMap : InlinerTreeMap = InlineTraitTreeMap ()
552
552
553
+ override protected def inlineCtx (inlineTyper : InlineTyper )(using Context ): Context =
554
+ ctx.fresh.setTyper(inlineTyper).setNewScope
555
+
553
556
private val paramAccessorsValueOf : Map [Name , Tree ] =
554
557
def allArgs (tree : Tree , acc : Vector [List [Tree ]]): List [List [Tree ]] = tree match
555
558
case Apply (fun, args) => allArgs(fun, acc :+ args)
@@ -620,7 +623,7 @@ object Inlines:
620
623
if vdef.symbol.isTermParamAccessor then
621
624
paramAccessorsValueOf(vdef.symbol.name)
622
625
else
623
- inlinedRhs(vdef.rhs.changeOwner(vdef.symbol , inlinedSym) )
626
+ inlinedRhs(vdef, inlinedSym)
624
627
tpd.ValDef (inlinedSym.asTerm, rhs).withSpan(parent.span)
625
628
626
629
private def inlinedDefDef (ddef : DefDef , inlinedSym : Symbol )(using Context ): DefDef =
@@ -631,7 +634,8 @@ object Inlines:
631
634
paramss =>
632
635
val oldParamSyms = ddef.paramss.flatten.map(_.symbol)
633
636
val newParamSyms = paramss.flatten.map(_.symbol)
634
- inlinedRhs(ddef.rhs.subst(oldParamSyms, newParamSyms).changeOwner(ddef.symbol, inlinedSym))
637
+ val ddef1 = cpy.DefDef (ddef)(rhs = ddef.rhs.subst(oldParamSyms, newParamSyms))
638
+ inlinedRhs(ddef1, inlinedSym)
635
639
tpd.DefDef (inlinedSym.asTerm, rhsFun).withSpan(parent.span)
636
640
637
641
private def inlinedPrimaryConstructorDefDef (ddef : DefDef )(using Context ): DefDef =
@@ -652,11 +656,12 @@ object Inlines:
652
656
private def inlinedTypeDef (tdef : TypeDef , inlinedSym : Symbol )(using Context ): TypeDef =
653
657
tpd.TypeDef (inlinedSym.asType).withSpan(parent.span)
654
658
655
- private def inlinedRhs (rhs : Tree ): Tree =
659
+ private def inlinedRhs (vddef : ValOrDefDef , inlinedSym : Symbol )(using Context ): Tree =
660
+ val rhs = vddef.rhs.changeOwner(vddef.symbol, inlinedSym)
656
661
if rhs.isEmpty then
657
662
rhs
658
663
else
659
- val inlinedRhs = inlined(rhs)._2
664
+ val inlinedRhs = inContext(ctx.withOwner(inlinedSym)) { inlined(rhs)._2 }
660
665
Inlined (tpd.ref(parentSym), Nil , inlinedRhs).withSpan(parent.span)
661
666
662
667
end InlineParentTrait
0 commit comments