From d07282d981a1bec9375f5e7b6a0353e8c62d9c71 Mon Sep 17 00:00:00 2001 From: odersky Date: Sun, 2 Jul 2023 15:56:59 +0200 Subject: [PATCH] Fix CaptureSet's -- --- compiler/src/dotty/tools/dotc/cc/CaptureSet.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala b/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala index fdc4f66beafa..fd07133b55e1 100644 --- a/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala +++ b/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala @@ -210,10 +210,11 @@ sealed abstract class CaptureSet extends Showable: * any of the elements in the constant capture set `that` */ def -- (that: CaptureSet.Const)(using Context): CaptureSet = - val elems1 = elems.filter(!that.accountsFor(_)) - if elems1.size == elems.size then this - else if this.isConst then Const(elems1) - else Diff(asVar, that) + if this.isConst then + val elems1 = elems.filter(!that.accountsFor(_)) + if elems1.size == elems.size then this else Const(elems1) + else + if that.isAlwaysEmpty then this else Diff(asVar, that) /** The largest subset (via <:<) of this capture set that does not account for `ref` */ def - (ref: CaptureRef)(using Context): CaptureSet =