Skip to content

Commit 6a08c89

Browse files
Make accessor values functions tailrec
Make the helper functions to compute parameters and arguments tail recursive, and insert elements in the right order to avoid doing `.reverse` afterwards Also remove "proxy" from "thisInlineTraitProxy", as it is not really a proxy
1 parent fb65487 commit 6a08c89

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ object Inlines:
470470
import tpd._
471471
import Inlines.*
472472

473-
private val thisInlineTraitProxy = ThisType.raw(TypeRef(ctx.owner.prefix, ctx.owner))
473+
private val thisInlineTrait = ThisType.raw(TypeRef(ctx.owner.prefix, ctx.owner))
474474

475475
def expandDefs(): List[Tree] =
476476
val tpd.Block(stats, _) = Inlines.bodyToInline(parentSym): @unchecked
@@ -481,26 +481,26 @@ object Inlines:
481481

482482
protected class InlineTraitTypeMap extends InlinerTypeMap {
483483
override def apply(t: Type) = t match {
484-
case t: ThisType if t.cls == parentSym => thisInlineTraitProxy
484+
case t: ThisType if t.cls == parentSym => thisInlineTrait
485485
case t => super.apply(t)
486486
}
487487
}
488488

489489
override protected val inlinerTypeMap: InlinerTypeMap = InlineTraitTypeMap()
490490

491491
private val paramAccessorsValueOf: Map[Name, Tree] =
492-
def allArgs(tree: Tree): List[List[Tree]] = tree match
493-
case Apply(fun, args) => args :: allArgs(fun)
494-
case TypeApply(fun, _) => allArgs(fun)
495-
case _ => Nil
496-
def allParams(info: Type): List[List[Name]] = info match
497-
case mt: MethodType => mt.paramNames :: allParams(mt.resultType)
498-
case pt: PolyType => allParams(pt.resultType)
499-
case _ => Nil
492+
def allArgs(tree: Tree, acc: Vector[List[Tree]]): List[List[Tree]] = tree match
493+
case Apply(fun, args) => allArgs(fun, acc :+ args)
494+
case TypeApply(fun, _) => allArgs(fun, acc)
495+
case _ => acc.toList
496+
def allParams(info: Type, acc: List[List[Name]]): List[List[Name]] = info match
497+
case mt: MethodType => allParams(mt.resultType, mt.paramNames :: acc)
498+
case pt: PolyType => allParams(pt.resultType, acc)
499+
case _ => acc
500500
val info =
501501
if parent.symbol.isClass then parent.symbol.primaryConstructor.info
502502
else parent.symbol.info
503-
allParams(info).flatten.zip(allArgs(parent).reverse.flatten).toMap
503+
allParams(info, Nil).flatten.zip(allArgs(parent, Vector.empty).flatten).toMap
504504

505505
private def isStatAlreadyOverridden(stat: Tree): Boolean =
506506
overriddenDecls.contains(stat.symbol)

0 commit comments

Comments
 (0)