Skip to content

Commit 80a5ec0

Browse files
Create vals for child type and child tree
1 parent 6024f02 commit 80a5ec0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,9 @@ object Inlines:
525525
private val paramAccessorsMapper = ParamAccessorsMapper()
526526
private val innerClassNewSyms: mutable.LinkedHashMap[Symbol, Symbol] = mutable.LinkedHashMap.empty
527527

528+
private val childThisType = ctx.owner.thisType
529+
private val childThisTree = This(ctx.owner.asClass).withSpan(parent.span)
530+
528531
def expandDefs(overriddenDecls: Set[Symbol]): List[Tree] =
529532
paramAccessorsMapper.registerParamValuesOf(parent)
530533
val stats = Inlines.defsToInline(parentSym).filterNot(stat => overriddenDecls.contains(stat.symbol))
@@ -534,17 +537,15 @@ object Inlines:
534537

535538
protected class InlineTraitTypeMap extends InlinerTypeMap {
536539
override def apply(t: Type) = super.apply(t) match {
537-
case t: ThisType if t.cls == parentSym =>
538-
ctx.owner.thisType
539-
case t =>
540-
mapOver(t)
540+
case t: ThisType if t.cls == parentSym => childThisType
541+
case t => mapOver(t)
541542
}
542543
}
543544

544545
protected class InlineTraitTreeMap extends InlinerTreeMap {
545546
override def apply(tree: Tree) = super.apply(tree) match {
546547
case tree: This if tree.symbol == parentSym =>
547-
Inlined(EmptyTree, Nil, This(ctx.owner.asClass).withSpan(parent.span)).withSpan(parent.span)
548+
Inlined(EmptyTree, Nil, childThisTree).withSpan(parent.span)
548549
case tree: This =>
549550
tree.tpe match {
550551
case thisTpe: ThisType if thisTpe.cls.isInlineTrait =>
@@ -593,7 +594,7 @@ object Inlines:
593594
inlinedTypeDef(stat, inlinedSym)
594595

595596
private def inlinedSym(sym: Symbol, withoutFlags: FlagSet = EmptyFlags)(using Context): Symbol =
596-
if sym.isClass then inlinedClassSym(sym.asClass, withoutFlags) else inlinedMemberSym(sym, withoutFlags)
597+
if sym.isClass then inlinedClassSym(sym.asClass, withoutFlags) else inlinedMemberSym(sym, withoutFlags)
597598

598599
private def inlinedClassSym(sym: ClassSymbol, withoutFlags: FlagSet = EmptyFlags)(using Context): ClassSymbol =
599600
sym.info match {

0 commit comments

Comments
 (0)