File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
compiler/src/dotty/tools/dotc/transform/init Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -290,13 +290,17 @@ object Semantic {
290
290
if current.contains(value, expr) then current(value)(expr)
291
291
else stable(value)(expr)
292
292
293
- def assume (value : Value , expr : Tree , cacheResult : Boolean )(fun : => Result ): Result =
294
- val assumeValue =
293
+ def assume (value : Value , expr : Tree , cacheResult : Boolean )(fun : => Result )( using Heap ) : Result =
294
+ val assumeValue : Value =
295
295
if last.contains(value, expr) then
296
- last.get(value, expr)
296
+ // Due to heap reverting, the object corresponding to a reference may not exist in the heap.
297
+ last.get(value, expr) match
298
+ case ref : Ref => ref.ensureObjectExists(); ref
299
+ case v => v
297
300
else
298
301
last.put(value, expr, Hot )
299
302
Hot
303
+ end if
300
304
current.put(value, expr, assumeValue)
301
305
302
306
val actual = fun
@@ -316,7 +320,10 @@ object Semantic {
316
320
actual
317
321
end assume
318
322
319
- /** Commit current cache to stable cache. */
323
+ /** Commit current cache to stable cache.
324
+ *
325
+ * TODO: It's useless to cache value for ThisRef.
326
+ */
320
327
def commit () =
321
328
current.foreach { (v, m) =>
322
329
m.iterator.foreach { (e, res) =>
You can’t perform that action at this time.
0 commit comments