Skip to content

Commit 8b00725

Browse files
committed
Add documentation
1 parent 1b3bda8 commit 8b00725

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,18 @@ class Semantic {
146146
* or `Hot`.
147147
*
148148
* 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.
153161
*/
154162
object Env {
155163
opaque type Env = Map[Symbol, Value]
@@ -453,7 +461,7 @@ class Semantic {
453461
val obj = Objekt(klass, fields = mutable.Map.empty, outers = mutable.Map(klass -> Hot))
454462
heap.update(value, obj)
455463
val res = value.call(ctor, args, superType = NoType, source)
456-
Result(res.value, res.errors)
464+
Result(value, res.errors)
457465

458466
case Cold =>
459467
val error = CallCold(ctor, source, trace1.toVector)

0 commit comments

Comments
 (0)