Skip to content

Commit f600df4

Browse files
committed
Improved documentation
Added explanations where suggested by Adriaan in his review.
1 parent f823e42 commit f600df4

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,18 @@ class Definitions {
437437
* to be the type parameters of a higher-kided type). This is a class symbol that
438438
* would be generated by the following schema.
439439
*
440-
* class LambdaXYZ { type v_1 Arg1; ...; type v_N ArgN; type Apply }
440+
* class LambdaXYZ extends Object with P1 with ... with Pn {
441+
* type v_1 $hk$Arg0; ...; type v_N $hk$ArgN;
442+
* type Apply
443+
* }
441444
*
442445
* Here:
443446
*
444-
* - XYZ is a string of length N with one letter for each variant of a bound symbols,
445-
* using `P` (positive variance), `N` (negative variance), `I` (invariant).
446447
* - v_i are the variances of the bound symbols (i.e. +, -, or empty).
448+
* - XYZ is a string of length N with one letter for each variant of a bound symbol,
449+
* using `P` (positive variance), `N` (negative variance), `I` (invariant).
450+
* - for each positive or negative variance v_i there is a parent trait Pj which
451+
* is the same as LambdaXYZ except that it has `I` in i-th position.
447452
*/
448453
def lambdaTrait(vcs: List[Int]): ClassSymbol = {
449454
assert(vcs.nonEmpty)

src/dotty/tools/dotc/core/TyperState.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ class TyperState(r: Reporter) extends DotClass with Showable {
2323
/** The uninstantiated variables */
2424
def uninstVars = constraint.uninstVars
2525

26-
/** The ephemeral flag */
26+
/** The ephemeral flag is set as a side effect if an operation accesses
27+
* the underlying type of a type variable. The reason we need this flag is
28+
* that any such operation is not referentially transparent; it might logically change
29+
* its value at the moment the type variable is instantiated. Caching code needs to
30+
* check the ephemeral flag; If the flag is set during an operation, the result
31+
* of that operation should not be cached.
32+
*/
2733
def ephemeral: Boolean = false
2834
def ephemeral_=(x: Boolean): Unit = ()
2935

src/dotty/tools/dotc/core/Types.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,8 @@ object Types {
654654
*
655655
* P { ... type T = / += / -= U ... } # T
656656
*
657-
* to just U
657+
* to just U. Does not perform the reduction if the resulting type would contain
658+
* a reference to the "this" of the current refined type.
658659
*/
659660
def lookupRefined(name: Name)(implicit ctx: Context): Type = stripTypeVar match {
660661
case pre: RefinedType =>

0 commit comments

Comments
 (0)