Skip to content

Commit 577b3a5

Browse files
committed
documenting box adaptation functions
1 parent 363f142 commit 577b3a5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ class CheckCaptures extends Recheck, SymTransformer:
605605

606606
/** Adapt function type `actual`, which is `aargs -> ares` (possibly with dependencies)
607607
* to `expected` type.
608+
* It returns the adapted type along with the additionally captured variable
609+
* during adaptation.
608610
* @param reconstruct how to rebuild the adapted function type
609611
*/
610612
def adaptFun(actual: Type, aargs: List[Type], ares: Type, expected: Type,
@@ -633,6 +635,9 @@ class CheckCaptures extends Recheck, SymTransformer:
633635
finally
634636
curEnv = saved
635637

638+
/** Adapt type function type `actual` to the expected type.
639+
* @see [[adaptFun]]
640+
*/
636641
def adaptTypeFun(
637642
actual: Type, ares: Type, expected: Type,
638643
covariant: Boolean, boxed: Boolean,
@@ -661,6 +666,13 @@ class CheckCaptures extends Recheck, SymTransformer:
661666
val arrow = if covariant then "~~>" else "<~~"
662667
i"adapting $actual $arrow $expected"
663668

669+
/** Destruct a capturing type `tp` to a tuple (cs, tp0, boxed),
670+
* where `tp0` is not a capturing type.
671+
*
672+
* If `tp` is a nested capturing type, the return tuple always represents
673+
* the innermost capturing type. The outer capture annotations can be
674+
* reconstructed with the returned function.
675+
*/
664676
def destructCapturingType(tp: Type, reconstruct: Type => Type = x => x): ((Type, CaptureSet, Boolean), Type => Type) =
665677
tp.dealias match
666678
case tp @ CapturingType(parent, cs) =>

0 commit comments

Comments
 (0)