Skip to content

Commit 4344f05

Browse files
committed
Fix backwards propagation in intersections
1 parent 1c14c77 commit 4344f05

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,11 +930,15 @@ object CaptureSet:
930930
deps += cs2
931931

932932
override def tryInclude(elem: Capability, origin: CaptureSet)(using Context, VarState): Boolean =
933-
val present =
933+
val inIntersection =
934934
if origin eq cs1 then cs2.accountsFor(elem)
935935
else if origin eq cs2 then cs1.accountsFor(elem)
936936
else true
937-
!present || accountsFor(elem) || addNewElem(elem)
937+
!inIntersection
938+
|| accountsFor(elem)
939+
|| addNewElem(elem)
940+
&& ((origin eq cs1) || cs1.tryInclude(elem, this))
941+
&& ((origin eq cs2) || cs2.tryInclude(elem, this))
938942

939943
override def computeApprox(origin: CaptureSet)(using Context): CaptureSet =
940944
if (origin eq cs1) || (origin eq cs2) then

0 commit comments

Comments
 (0)