Skip to content

Commit df57c0b

Browse files
committed
Null out closure in LazyRef after use
1 parent f1cd684 commit df57c0b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,13 +2146,15 @@ object Types {
21462146
}
21472147

21482148
case class LazyRef(refFn: () => Type) extends UncachedProxyType with ValueType {
2149+
private var myRefFn: () => Type = refFn
21492150
private var myRef: Type = null
21502151
private var computed = false
21512152
def ref = {
21522153
if (computed) assert(myRef != null)
21532154
else {
21542155
computed = true
2155-
myRef = refFn()
2156+
myRef = myRefFn()
2157+
myRefFn = null // null out to avoid memory leak
21562158
}
21572159
myRef
21582160
}

0 commit comments

Comments
 (0)