@@ -146,10 +146,18 @@ class Semantic {
146
146
* or `Hot`.
147
147
*
148
148
* Despite that we have environment for evaluating expressions in secondary
149
- * constructors (currently we restrict method arguments to be hot), we don't
150
- * need to put environment as the cache key. The reason is that constructor
151
- * parameters are determined by the value of `this` --- it suffices to make
152
- * the value of `this` as part of the cache key.
149
+ * constructors, we don't need to put environment as the cache key. The
150
+ * reason is that constructor parameters are determined by the value of
151
+ * `this` --- it suffices to make the value of `this` as part of the cache
152
+ * key.
153
+ *
154
+ * This crucially depends on the fact that in the initialization process
155
+ * there can be exactly one call to a specific constructor for a given
156
+ * receiver. However, once we relax the design to allow non-hot values to
157
+ * methods and functions, we have to put the environment as part of the cache
158
+ * key. The reason is that given the same receiver, a method or function may
159
+ * be called with different arguments -- they are not decided by the receiver
160
+ * anymore.
153
161
*/
154
162
object Env {
155
163
opaque type Env = Map [Symbol , Value ]
@@ -453,7 +461,7 @@ class Semantic {
453
461
val obj = Objekt (klass, fields = mutable.Map .empty, outers = mutable.Map (klass -> Hot ))
454
462
heap.update(value, obj)
455
463
val res = value.call(ctor, args, superType = NoType , source)
456
- Result (res. value, res.errors)
464
+ Result (value, res.errors)
457
465
458
466
case Cold =>
459
467
val error = CallCold (ctor, source, trace1.toVector)
0 commit comments