Skip to content

Commit 7919c42

Browse files
committed
Fix primitive value optimization
1 parent 6726bb7 commit 7919c42

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler/src/dotty/tools/dotc/transform/init/Objects.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ object Objects:
226226

227227
def read(ref: Ref, field: Symbol)(using state: State.Data): Value =
228228
val data: Data = State.getHeap()
229-
data.map(Addr(ref, field))
229+
// Primitive values are not in the heap and initialization errors are reported by the initialization checker.
230+
data.map.getOrElse(Addr(ref, field), Bottom)
230231

231232
def write(ref: Ref, field: Symbol, value: Value)(using state: State.Data): Unit =
232233
val addr = Addr(ref, field)

0 commit comments

Comments
 (0)