@@ -312,13 +312,7 @@ object Semantic {
312
312
*
313
313
* 2. Reset current cache (last cache already synced in `assume`)
314
314
*
315
- * 3. Recompute the newly created warm objects with the updated cache.
316
- *
317
- * The computation only covers class parameters and outers. Class
318
- * fields are ignored and are lazily evaluated and cached.
319
- *
320
- * This step should be after the first two steps so that the populated
321
- * parameter are re-computed from the updated input cache.
315
+ * 3. Revert heap if instable.
322
316
*
323
317
*/
324
318
def prepareForNextIteration (isStable : Boolean )(using State , Context ) =
@@ -470,6 +464,12 @@ object Semantic {
470
464
*/
471
465
def updateField (field : Symbol , value : Value ): Contextual [Unit ] = log(" set field " + field + " of " + ref + " to " + value) {
472
466
val obj = objekt
467
+ // We may reset the outers or params of a populated warm object.
468
+ // This is the case if we need access the field of a warm object, which
469
+ // requires population of parameters and outers; and later create an
470
+ // instance of the exact warm object, which requires initialization check.
471
+ //
472
+ // See tests/init/neg/unsound1.scala
473
473
assert(! obj.hasField(field) || field.is(Flags .ParamAccessor ) && obj.field(field) == value, field.show + " already init, new = " + value + " , old = " + obj.field(field) + " , ref = " + ref)
474
474
val obj2 = obj.copy(fields = obj.fields.updated(field, value))
475
475
cache.updateObject(ref, obj2)
@@ -481,6 +481,7 @@ object Semantic {
481
481
*/
482
482
def updateOuter (klass : ClassSymbol , value : Value ): Contextual [Unit ] = log(" set outer " + klass + " of " + ref + " to " + value) {
483
483
val obj = objekt
484
+ // See the comment in `updateField` for setting the value twice.
484
485
assert(! obj.hasOuter(klass) || obj.outer(klass) == value, klass.show + " already has outer, new = " + value + " , old = " + obj.outer(klass) + " , ref = " + ref)
485
486
val obj2 = obj.copy(outers = obj.outers.updated(klass, value))
486
487
cache.updateObject(ref, obj2)
0 commit comments