Skip to content

Commit b646a27

Browse files
Linyxusolhotak
authored andcommitted
Fix capture set handling in distributeAnd
1 parent 6929e77 commit b646a27

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
@@ -2618,10 +2618,12 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
26182618
case tp1: TypeVar if tp1.isInstantiated =>
26192619
tp1.underlying & tp2
26202620
case CapturingType(parent1, refs1) =>
2621-
if subCaptures(tp2.captureSet, refs1, frozen = true).isOK
2621+
val refs2 = tp2.captureSet
2622+
if subCaptures(refs2, refs1, frozen = true).isOK
26222623
&& tp1.isBoxedCapturing == tp2.isBoxedCapturing
26232624
then
2624-
parent1 & tp2
2625+
if refs2.isAlwaysEmpty then parent1 & tp2
2626+
else (parent1 & tp2).capturing(refs2)
26252627
else
26262628
tp1.derivedCapturingType(parent1 & tp2, refs1)
26272629
case tp1: AnnotatedType if !tp1.isRefining =>

0 commit comments

Comments
 (0)