Skip to content

Commit 9c38a61

Browse files
committed
Make LazyRef#ref a def instead of a lazy val
It's slightly more efficient. There was no need to have a separate cache for the lazy val.
1 parent 9d8c92d commit 9c38a61

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/dotty/tools/dotc/core/Types.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1972,14 +1972,15 @@ object Types {
19721972
case class LazyRef(refFn: () => Type) extends UncachedProxyType with ValueType {
19731973
private var myRef: Type = null
19741974
private var computed = false
1975-
lazy val ref = {
1975+
def ref = {
19761976
if (computed) assert(myRef != null)
19771977
else {
19781978
computed = true
19791979
myRef = refFn()
19801980
}
19811981
myRef
19821982
}
1983+
def evaluating = computed && myRef == null
19831984
override def underlying(implicit ctx: Context) = ref
19841985
override def toString = s"LazyRef($ref)"
19851986
override def equals(other: Any) = other match {

0 commit comments

Comments
 (0)