Skip to content

Commit 3e2d6aa

Browse files
committed
Polishings
1 parent 77d08ef commit 3e2d6aa

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,8 @@ extension (tp: Type)
4242
else CapturingType(parent, refs, tp.isBoxed)
4343

4444
def boxed(using Context): Type = tp.dealias match
45-
case tp @ CapturingType(parent, refs) =>
46-
def boxedTp = parent.boxed match
47-
case CapturingType(parent1, refs1) =>
48-
CapturingType(parent1, refs ++ refs1, boxed = true)
49-
case parent1 =>
50-
CapturingType(parent1, refs, boxed = true)
51-
if tp.isBoxed || refs.isAlwaysEmpty then tp
52-
else tp.annot match
45+
case tp @ CapturingType(parent, refs) if !tp.isBoxed && !refs.isAlwaysEmpty =>
46+
tp.annot match
5347
case ann: CaptureAnnotation =>
5448
ann.boxedType(tp)
5549
case ann =>
@@ -64,7 +58,6 @@ extension (tp: Type)
6458
if ctx.phase != Phases.checkCapturesPhase || defn.isFunctionClass(tycon.typeSymbol)
6559
then tp
6660
else tp.boxed
67-
//.showing(i"boxedUF $tp in $tycon = $result")
6861

6962
/** The boxed capture set of a type */
7063
def boxedCaptureSet(using Context): CaptureSet =

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ object CapturingType:
1414
if refs.isAlwaysEmpty then parent
1515
else parent match
1616
case parent @ CapturingType(parent1, refs1) if boxed || !parent.isBoxed =>
17+
// Fuse types except if nested type is boxed and current one isn't.
1718
apply(parent1, refs ++ refs1, boxed)
1819
case _ =>
1920
AnnotatedType(parent, CaptureAnnotation(refs, boxed)(defn.RetainsAnnot))

0 commit comments

Comments
 (0)