@@ -125,7 +125,7 @@ var x: T = _
125
125
Monotonicity means that the initialization status of an object should
126
126
not go backward: initialized fields continue to be initialized, a
127
127
field points to an initialized object may not later point to an
128
- object under initialization. It means the following code will be rejected:
128
+ object under initialization. As an example, the following code will be rejected:
129
129
130
130
``` scala
131
131
trait Reporter { def report (msg : String ): Unit }
@@ -231,26 +231,27 @@ We impose the following rules to enforce modularity:
231
231
232
232
Theoretically, we may analyze across project boundaries based on tasty. However,
233
233
from our experience with Dotty community projects, most subtle initialization
234
- patterns are restricted in the same project. We think it is good to first impose
235
- more strict rules. The feedback from the community is welcome.
234
+ patterns are restricted in the same project. As the rules only report warnings
235
+ instead of errors, we think it is good to first impose more strict rules, The
236
+ feedback from the community is welcome.
236
237
237
238
## Theory
238
239
239
240
The theory is based on type-and-effect systems [ 1] . We introduce two concepts,
240
241
_ effects_ and _ potentials_ :
241
242
242
243
```
243
- π = C.this | Warm[ C, π] | π.f | π.m | C .super[D] | Cold | Fun(Π, Φ) | Outer(C, π)
244
+ π = C.this | Warm( C, π) | π.f | π.m | π .super[D] | Cold | Fun(Π, Φ) | Outer(C, π)
244
245
ϕ = π↑ | π.f! | π.m!
245
246
```
246
247
247
248
Potentials (π) represent values that are possibly under initialization.
248
249
249
250
- ` C.this ` : current object
250
- - ` Warm[ C, π] ` : an object of type ` C ` where all its fields are assigned, and the potential for ` this ` of its enclosing class is ` π ` .
251
+ - ` Warm( C, π) ` : an object of type ` C ` where all its fields are assigned, and the potential for ` this ` of its enclosing class is ` π ` .
251
252
- ` π.f ` : the potential of the field ` f ` in the potential ` π `
252
253
- ` π.m ` : the potential of the field ` f ` in the potential ` π `
253
- - ` C .super[D]` : essentially the current object, used for virtual method resolution
254
+ - ` π .super[D]` : essentially the object π , used for virtual method resolution
254
255
- ` Cold ` : an object with unknown initialization status
255
256
- ` Fun(Π, Φ) ` : a function, when called produce effects Φ and return potentials Π.
256
257
- ` Outer(C, π) ` : the potential of ` this ` for the enclosing class of ` C ` when ` C.this ` is ` π ` .
0 commit comments