Skip to content

Commit b14969c

Browse files
committed
Address reviewers comments
1 parent 7017181 commit b14969c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

compiler/src/dotty/tools/dotc/transform/ByNameClosures.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ByNameClosures extends TransformByNameApply with IdentityDenotTransformer
2929

3030
override def phaseName: String = "byNameClosures"
3131

32-
override def mkClosure(arg: Tree, argType: Type)(implicit ctx: Context): Tree = {
32+
override def mkByNameClosure(arg: Tree, argType: Type)(implicit ctx: Context): Tree = {
3333
val meth = ctx.newSymbol(
3434
ctx.owner, nme.ANON_FUN, Synthetic | Method, MethodType(Nil, Nil, argType))
3535
Closure(meth, _ => arg.changeOwnerAfter(ctx.owner, meth, thisTransformer))

compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,12 @@ class HoistSuperArgs extends MiniPhaseTransform with IdentityDenotTransformer {
123123
val paramSyms = trefs.map(_.typeSymbol) ::: vrefss.flatten.map(_.symbol)
124124
val tmap = new TreeTypeMap(
125125
typeMap = new TypeMap {
126+
lazy val origToParam = origParams.zip(paramSyms).toMap
126127
def apply(tp: Type) = tp match {
127128
case tp: NamedType
128129
if (tp.symbol.owner == cls || tp.symbol.owner == constr) &&
129130
tp.symbol.is(ParamOrAccessor) =>
130-
val mappedSym = origParams.zip(paramSyms).toMap.apply(tp.symbol)
131+
val mappedSym = origToParam(tp.symbol)
131132
if (tp.symbol.isType) mappedSym.typeRef else mappedSym.termRef
132133
case _ =>
133134
mapOver(tp)

compiler/src/dotty/tools/dotc/transform/TransformByNameApply.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import ast.Trees._
1919
abstract class TransformByNameApply extends MiniPhaseTransform { thisTransformer: DenotTransformer =>
2020
import ast.tpd._
2121

22-
/** The info of the tree's symbol at phase Nullarify (i.e. before transformation) */
22+
/** The info of the tree's symbol before it is potentially transformed in this phase */
2323
private def originalDenotation(tree: Tree)(implicit ctx: Context) =
2424
tree.symbol.denot(ctx.withPhase(thisTransformer))
2525

@@ -32,7 +32,7 @@ abstract class TransformByNameApply extends MiniPhaseTransform { thisTransformer
3232
origDenot.info.isInstanceOf[ExprType] && exprBecomesFunction(origDenot)
3333
}
3434

35-
def mkClosure(arg: Tree, argType: Type)(implicit ctx: Context): Tree = unsupported(i"mkClosure($arg)")
35+
def mkByNameClosure(arg: Tree, argType: Type)(implicit ctx: Context): Tree = unsupported(i"mkClosure($arg)")
3636

3737
override def transformApply(tree: Apply)(implicit ctx: Context, info: TransformerInfo): Tree =
3838
ctx.traceIndented(s"transforming ${tree.show} at phase ${ctx.phase}", show = true) {
@@ -48,7 +48,7 @@ abstract class TransformByNameApply extends MiniPhaseTransform { thisTransformer
4848
wrap(qual)
4949
case _ =>
5050
if (isByNameRef(arg) || arg.symbol == defn.cbnArg) arg
51-
else wrap(mkClosure(arg, argType))
51+
else wrap(mkByNameClosure(arg, argType))
5252
}
5353
case _ =>
5454
arg

0 commit comments

Comments
 (0)