Skip to content

Commit 8cce121

Browse files
Merge pull request #5884 from dotty-staging/simplify-inliner
Sharpen a type in Inliner
2 parents f31a876 + 100248e commit 8cce121

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
208208
private val thisProxy = new mutable.HashMap[ClassSymbol, TermRef]
209209

210210
/** A buffer for bindings that define proxies for actual arguments */
211-
private val bindingsBuf = new mutable.ListBuffer[MemberDef]
211+
private val bindingsBuf = new mutable.ListBuffer[ValOrDefDef]
212212

213213
private def newSym(name: Name, flags: FlagSet, info: Type): Symbol =
214214
ctx.newSymbol(ctx.owner, name, flags, info, coord = call.span)
@@ -223,7 +223,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
223223
* @param bindingsBuf the buffer to which the definition should be appended
224224
*/
225225
private def paramBindingDef(name: Name, paramtp: Type, arg: Tree,
226-
bindingsBuf: mutable.ListBuffer[MemberDef]): MemberDef = {
226+
bindingsBuf: mutable.ListBuffer[ValOrDefDef]): ValOrDefDef = {
227227
val argtpe = arg.tpe.dealiasKeepAnnots
228228
val isByName = paramtp.dealias.isInstanceOf[ExprType]
229229
var inlineFlag = InlineProxy
@@ -585,7 +585,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
585585
* - reduce its rhs if it is a projection and adjust its type accordingly,
586586
* - record symbol -> rhs in the InlineBindings context propery.
587587
*/
588-
def normalizeBinding(binding: MemberDef)(implicit ctx: Context) = {
588+
def normalizeBinding(binding: ValOrDefDef)(implicit ctx: Context) = {
589589
val binding1 = binding match {
590590
case binding: ValDef =>
591591
val rhs1 = reduceProjection(binding.rhs)
@@ -608,7 +608,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
608608
private object InlineableArg {
609609
lazy val paramProxies = paramProxy.values.toSet
610610
def unapply(tree: Trees.Ident[_])(implicit ctx: Context): Option[Tree] = {
611-
def search(buf: mutable.ListBuffer[MemberDef]) = buf.find(_.name == tree.name)
611+
def search(buf: mutable.ListBuffer[ValOrDefDef]) = buf.find(_.name == tree.name)
612612
if (paramProxies.contains(tree.typeOpt))
613613
search(bindingsBuf) match {
614614
case Some(vdef: ValDef) if vdef.symbol.is(Inline) =>
@@ -651,7 +651,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
651651
case Apply(Select(cl @ closureDef(ddef), nme.apply), args) if defn.isFunctionType(cl.tpe) =>
652652
ddef.tpe.widen match {
653653
case mt: MethodType if ddef.vparamss.head.length == args.length =>
654-
val bindingsBuf = new mutable.ListBuffer[MemberDef]
654+
val bindingsBuf = new mutable.ListBuffer[ValOrDefDef]
655655
val argSyms = (mt.paramNames, mt.paramInfos, args).zipped.map { (name, paramtp, arg) =>
656656
arg.tpe.dealias match {
657657
case ref @ TermRef(NoPrefix, _) => ref.symbol
@@ -694,7 +694,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
694694
* bindings for variables bound in this pattern to `bindingsBuf`.
695695
*/
696696
def reducePattern(
697-
bindingsBuf: mutable.ListBuffer[MemberDef],
697+
bindingsBuf: mutable.ListBuffer[ValOrDefDef],
698698
fromBuf: mutable.ListBuffer[TypeSymbol],
699699
toBuf: mutable.ListBuffer[TypeSymbol],
700700
scrut: TermRef,
@@ -859,7 +859,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
859859
val scrutineeBinding = normalizeBinding(ValDef(scrutineeSym, scrutinee))
860860

861861
def reduceCase(cdef: CaseDef): MatchRedux = {
862-
val caseBindingsBuf = new mutable.ListBuffer[MemberDef]()
862+
val caseBindingsBuf = new mutable.ListBuffer[ValOrDefDef]()
863863
def guardOK(implicit ctx: Context) = cdef.guard.isEmpty || {
864864
val guardCtx = ctx.fresh.setNewScope
865865
caseBindingsBuf.foreach(binding => guardCtx.enter(binding.symbol))
@@ -1105,7 +1105,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
11051105
)
11061106

11071107
val Block(termBindings1, tree1) = inlineTypeBindings(Block(termBindings, tree))
1108-
inlineTermBindings(termBindings1.asInstanceOf[List[MemberDef]], tree1)
1108+
inlineTermBindings(termBindings1.asInstanceOf[List[ValOrDefDef]], tree1)
11091109
}
11101110
}
11111111
}

0 commit comments

Comments
 (0)