Skip to content

Commit 67ba7b5

Browse files
committed
Micro-optimization: avoid lazy val in hot path
1 parent 1dd8196 commit 67ba7b5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,12 +1137,17 @@ class Namer { typer: Typer =>
11371137
}
11381138

11391139
def cookedRhsType = deskolemize(dealiasIfUnit(widenRhs(rhsType)))
1140-
lazy val lhsType = fullyDefinedType(cookedRhsType, "right-hand side", mdef.pos)
1140+
def lhsType = fullyDefinedType(cookedRhsType, "right-hand side", mdef.pos)
11411141
//if (sym.name.toString == "y") println(i"rhs = $rhsType, cooked = $cookedRhsType")
1142-
if (inherited.exists)
1143-
if (sym.is(Final, butNot = Method) && lhsType.isInstanceOf[ConstantType])
1144-
lhsType // keep constant types that fill in for a non-constant (to be revised when inline has landed).
1142+
if (inherited.exists) {
1143+
if (sym.is(Final, butNot = Method)) {
1144+
val tp = lhsType
1145+
if (tp.isInstanceOf[ConstantType])
1146+
tp // keep constant types that fill in for a non-constant (to be revised when inline has landed).
1147+
else inherited
1148+
}
11451149
else inherited
1150+
}
11461151
else {
11471152
if (sym is Implicit)
11481153
mdef match {

0 commit comments

Comments
 (0)