Skip to content

Commit 7f20c7f

Browse files
committed
Fix capture set handling in distributeAnd
1 parent 816bd5e commit 7f20c7f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,10 +2610,12 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
26102610
case tp1: TypeVar if tp1.isInstantiated =>
26112611
tp1.underlying & tp2
26122612
case CapturingType(parent1, refs1) =>
2613-
if subCaptures(tp2.captureSet, refs1, frozen = true).isOK
2613+
val refs2 = tp2.captureSet
2614+
if subCaptures(refs2, refs1, frozen = true).isOK
26142615
&& tp1.isBoxedCapturing == tp2.isBoxedCapturing
26152616
then
2616-
parent1 & tp2
2617+
if refs2.isAlwaysEmpty then parent1 & tp2
2618+
else (parent1 & tp2).capturing(refs2)
26172619
else
26182620
tp1.derivedCapturingType(parent1 & tp2, refs1)
26192621
case tp1: AnnotatedType if !tp1.isRefining =>

0 commit comments

Comments
 (0)