Skip to content

Commit de1066a

Browse files
committed
Update docs of WithLazyFields
1 parent a42ea67 commit de1066a

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,24 +1016,27 @@ object Trees {
10161016

10171017
// ----- Lazy trees and tree sequences
10181018

1019-
/** A tree that can have a lazy field
1020-
* The field is represented by some private `var` which is
1021-
* accessed by `unforced` and `force`. Forcing the field will
1022-
* set the `var` to the underlying value.
1019+
/** A base trait for lazy tree fields.
1020+
* These can be instantiated with Lazy instances which
1021+
* can delay tree construction until the field is first demanded.
1022+
*/
1023+
trait Lazy[+T <: AnyRef]:
1024+
def complete(using Context): T
1025+
1026+
/** A tree that can have a lazy fields.
1027+
* Such fields are variables of type `T | Lazy[T]`, for some tyope `T`.
10231028
*/
10241029
trait WithLazyFields:
1030+
1031+
/** If `x` is lazy, computes the underlying value */
10251032
protected def force[T <: AnyRef](x: T | Lazy[T])(using Context): T = x match
10261033
case x: Lazy[T] @unchecked => x.complete
10271034
case x: T @unchecked => x
1035+
1036+
/** Assigns all lazy fields their underlying non-lazy value. */
10281037
def forceFields()(using Context): Unit
10291038

1030-
/** A base trait for lazy tree fields.
1031-
* These can be instantiated with Lazy instances which
1032-
* can delay tree construction until the field is first demanded.
1033-
*/
1034-
trait Lazy[+T <: AnyRef] {
1035-
def complete(using Context): T
1036-
}
1039+
end WithLazyFields
10371040

10381041
// ----- Generic Tree Instances, inherited from `tpt` and `untpd`.
10391042

0 commit comments

Comments
 (0)