Skip to content

Commit 7ee58a3

Browse files
committed
Address review: Add comment to populateParams
1 parent 15a51d7 commit 7ee58a3

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ object Semantic {
9292
/** Ensure that outers and class parameters are initialized.
9393
*
9494
* Fields in class body are not initialized.
95+
*
96+
* We need to populate class parameters and outers for warm values for the
97+
* following cases:
98+
*
99+
* - Widen an already checked warm value to another warm value without
100+
* corresponding object
101+
*
102+
* - Using a warm value from the cache, whose corresponding object from
103+
* the last iteration have been remove due to heap reversion
104+
* {@see Cache.prepareForNextIteration}
105+
*
106+
* After populating class parameters and outers, it is possible to lazily
107+
* compute the field values in class bodies when they are accessed.
95108
*/
96109
private def populateParams(): Contextual[this.type] = log("populating parameters", printer, (_: Warm).objekt.toString) {
97110
assert(!populatingParams, "the object is already populating parameters")
@@ -255,11 +268,13 @@ object Semantic {
255268
*
256269
* The fact that objects of `ThisRef` are stored in heap is just an engineering convenience.
257270
* Technically, we can also store the object directly in `ThisRef`.
258-
*
259-
* The heap contains objects of two conceptually distinct kinds.
260-
* - Objects that are also in `heapStable`
261-
* are flow-insensitive views of already initialized objects that are cached for reuse in analysis of later
262-
* classes. These objects and their fields should never change; this is enforced using assertions.
271+
*
272+
* The heap contains objects of two conceptually distinct kinds.
273+
*
274+
* - Objects that are also in `heapStable` are flow-insensitive views of already initialized objects that are
275+
* cached for reuse in analysis of later classes. These objects and their fields should never change; this is
276+
* enforced using assertions.
277+
*
263278
* - Objects that are not (yet) in `heapStable` are the flow-sensitive abstract state of objects being analyzed
264279
* in the current iteration of the analysis of the current class. Their fields do change flow-sensitively: more
265280
* fields are added as fields become initialized. These objects are valid only within the current iteration and
@@ -272,7 +287,6 @@ object Semantic {
272287

273288
/** Used to revert heap to last stable heap. */
274289
private var heapStable: Heap = Map.empty
275-
def stableHeapContains(ref: Ref) = heapStable.contains(ref)
276290

277291
def hasChanged = changed
278292

0 commit comments

Comments
 (0)