Skip to content

Commit 2f6cb08

Browse files
committed
Fix LazyRef closure removal.
The previous attempt did not actually remove the closure, since LazyRef is a case class.
1 parent 49fd9bd commit 2f6cb08

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,16 +2156,14 @@ object Types {
21562156
}
21572157
}
21582158

2159-
case class LazyRef(refFn: () => Type) extends UncachedProxyType with ValueType {
2160-
private var myRefFn: () => Type = refFn
2159+
case class LazyRef(private var refFn: () => Type) extends UncachedProxyType with ValueType {
21612160
private var myRef: Type = null
21622161
private var computed = false
21632162
def ref = {
21642163
if (computed) assert(myRef != null)
21652164
else {
21662165
computed = true
2167-
myRef = myRefFn()
2168-
myRefFn = null // null out to avoid memory leak
2166+
myRef = refFn()
21692167
}
21702168
myRef
21712169
}

0 commit comments

Comments
 (0)