Skip to content

Commit fab653e

Browse files
committed
Add documentation about caching
1 parent 11d46bc commit fab653e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Semantic {
5555
* V ⊑ R if V ∈ R
5656
*
5757
*/
58-
sealed abstract class Value extends Cloneable {
58+
sealed abstract class Value {
5959
def show: String = this.toString()
6060
}
6161

@@ -142,7 +142,14 @@ class Semantic {
142142

143143
/** The environment for method parameters
144144
*
145-
* For performance and usability, we restrict parameters to be either `Cold` or `Hot`.
145+
* For performance and usability, we restrict parameters to be either `Cold`
146+
* or `Hot`.
147+
*
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.
146153
*/
147154
object Env {
148155
opaque type Env = Map[Symbol, Value]

0 commit comments

Comments
 (0)