Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/transform/init/Objects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ class Objects(using Context @constructorOnly):

def getHeapData()(using mutable: MutableData): Data = mutable.heap

def setHeap(newHeap: Data)(using mutable: MutableData): Unit = mutable.heap = newHeap

/** Cache used to terminate the check */
object Cache:
case class Config(thisV: Value, env: Env.Data, heap: Heap.Data)
Expand All @@ -538,6 +540,7 @@ class Objects(using Context @constructorOnly):
val result = super.cachedEval(config, expr, cacheResult, default = Res(Bottom, Heap.getHeapData())) { expr =>
Res(fun(expr), Heap.getHeapData())
}
Heap.setHeap(result.heap)
result.value
end Cache

Expand Down
17 changes: 17 additions & 0 deletions tests/init-global/pos/scodec-bits.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
abstract class A {
def a: Long
}

object O {
case class B() extends A {
def a = 5L
}
case class C(a2: A) extends A {
var c: Long = a2.a
def a = c
}
def f(a: A): A = C(f(a))
def g(): A = f(B())

val x = g()
}