Skip to content

Commit 7bdb249

Browse files
liufengyunmlachkar
andcommitted
Fix memory leak through NoDenotation.cachePrefix
We may set `NoDenotation.cachePrefix` in `Denotation.asSeenFrom`, thus leak memory. This memory leak is discovered by @mlachkar. Co-authored-by: Meriam Lachkar <[email protected]>
1 parent 5e0100d commit 7bdb249

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ object Denotations {
130130

131131
/** The denotation with info(s) as seen from prefix type */
132132
final def asSeenFrom(pre: Type)(using Context): AsSeenFromResult =
133-
if (Config.cacheAsSeenFrom) {
133+
if (Config.cacheAsSeenFrom && exists) {
134134
if ((cachedPrefix ne pre) || ctx.period != validAsSeenFrom) {
135135
cachedAsSeenFrom = computeAsSeenFrom(pre)
136136
cachedPrefix = pre

0 commit comments

Comments
 (0)