Skip to content

Commit 8951bc0

Browse files
committed
Address review: factor out isByNameParam
1 parent d6629e8 commit 8951bc0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

compiler/src/dotty/tools/dotc/transform/init/Objects.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,6 @@ object Objects:
648648
if ctor.isPrimaryConstructor then
649649
val tpl = cls.defTree.asInstanceOf[TypeDef].rhs.asInstanceOf[Template]
650650
extendTrace(cls.defTree) { eval(tpl, ref, cls, cacheResult = true) }
651-
ref
652651
else
653652
extendTrace(ddef) { eval(ddef.rhs, ref, cls, cacheResult = true) }
654653
else
@@ -817,6 +816,7 @@ object Objects:
817816
* @param sym The symbol of the variable.
818817
*/
819818
def readLocal(thisV: Value, sym: Symbol): Contextual[Value] = log("reading local " + sym.show, printer, (_: Value).show) {
819+
def isByNameParam(sym: Symbol) = sym.is(Flags.Param) && sym.info.isInstanceOf[ExprType]
820820
Env.resolveEnv(sym.enclosingMethod, thisV, summon[Env.Data]) match
821821
case Some(thisV -> env) =>
822822
if sym.is(Flags.Mutable) then
@@ -837,7 +837,7 @@ object Objects:
837837
try
838838
// Assume forward reference check is doing a good job
839839
val value = Env.valValue(sym)
840-
if sym.is(Flags.Param) && sym.info.isInstanceOf[ExprType] then
840+
if isByNameParam(sym) then
841841
value match
842842
case fun: Fun =>
843843
given Env.Data = fun.env
@@ -856,7 +856,7 @@ object Objects:
856856
Bottom
857857

858858
case _ =>
859-
if sym.is(Flags.Param) && sym.info.isInstanceOf[ExprType] then
859+
if isByNameParam(sym) then
860860
report.warning("Calling cold by-name alias. Call trace: \n" + Trace.show, Trace.position)
861861
Bottom
862862
else
@@ -1089,10 +1089,10 @@ object Objects:
10891089
eval(expr, thisV, klass)
10901090

10911091
case Try(block, cases, finalizer) =>
1092-
eval(block, thisV, klass)
1092+
val res = evalExprs(block :: cases.map(_.body), thisV, klass).join
10931093
if !finalizer.isEmpty then
10941094
eval(finalizer, thisV, klass)
1095-
evalExprs(cases.map(_.body), thisV, klass).join
1095+
res
10961096

10971097
case SeqLiteral(elems, elemtpt) =>
10981098
evalExprs(elems, thisV, klass).join

0 commit comments

Comments
 (0)