Skip to content

Commit 49fd9bd

Browse files
committed
Null out closure in LazyRef after use
1 parent 221320f commit 49fd9bd

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
@@ -2157,13 +2157,15 @@ object Types {
21572157
}
21582158

21592159
case class LazyRef(refFn: () => Type) extends UncachedProxyType with ValueType {
2160+
private var myRefFn: () => Type = refFn
21602161
private var myRef: Type = null
21612162
private var computed = false
21622163
def ref = {
21632164
if (computed) assert(myRef != null)
21642165
else {
21652166
computed = true
2166-
myRef = refFn()
2167+
myRef = myRefFn()
2168+
myRefFn = null // null out to avoid memory leak
21672169
}
21682170
myRef
21692171
}

0 commit comments

Comments
 (0)