@@ -269,11 +269,9 @@ object CaptureSet:
269
269
if ! isConst && recordElemsState() then
270
270
elems ++= newElems
271
271
// assert(id != 2 || elems.size != 2, this)
272
- val depsIt = deps.iterator
273
- while depsIt.hasNext do
274
- val result = depsIt.next.tryInclude(newElems, this )
275
- if ! result.isOK then return result
276
- CompareResult .OK
272
+ (CompareResult .OK /: deps) { (r, dep) =>
273
+ r.andAlso(dep.tryInclude(newElems, this ))
274
+ }
277
275
else
278
276
CompareResult .fail(this )
279
277
@@ -359,12 +357,12 @@ object CaptureSet:
359
357
report.warning(i " trying to add elems $newElems from unrecognized source $origin of mapped set $this$whereCreated" )
360
358
return CompareResult .fail(this )
361
359
Const (newElems)
362
- val result = super .addNewElems(added.elems, origin)
363
- if result.isOK then
364
- if added.isConst then result
365
- else if added.asVar.recordDepsState() then { addSub(added); result }
366
- else CompareResult .fail(this )
367
- else result
360
+ super .addNewElems(added.elems, origin)
361
+ .andAlso {
362
+ if added.isConst then CompareResult . OK
363
+ else if added.asVar.recordDepsState() then { addSub(added); CompareResult . OK }
364
+ else CompareResult .fail(this )
365
+ }
368
366
369
367
override def computeApprox (origin : CaptureSet )(using Context ): CaptureSet =
370
368
if source eq origin then universal
@@ -384,11 +382,11 @@ object CaptureSet:
384
382
if origin eq source then
385
383
super .addNewElems(newElems.map(bimap.forward), origin)
386
384
else
387
- val r = super .addNewElems(newElems, origin)
388
- if r.isOK then
389
- source.tryInclude(newElems.map(bimap.backward), this )
390
- .showing(i " propagating new elems $newElems backward from $this to $source" , capt)
391
- else r
385
+ super .addNewElems(newElems, origin)
386
+ .andAlso {
387
+ source.tryInclude(newElems.map(bimap.backward), this )
388
+ .showing(i " propagating new elems $newElems backward from $this to $source" , capt)
389
+ }
392
390
393
391
override def computeApprox (origin : CaptureSet )(using Context ): CaptureSet =
394
392
val supApprox = super .computeApprox(this )
@@ -448,7 +446,7 @@ object CaptureSet:
448
446
def isOK : Boolean = result eq OK
449
447
def blocking : CaptureSet = result
450
448
def show : String = if result.isOK then " OK" else result.toString
451
- inline def andAlso (op : => Type ) = if result.isOK then op else result
449
+ def andAlso (op : Context ? => Type )( using Context ) : Type = if result.isOK then op else result
452
450
453
451
class VarState :
454
452
private val elemsMap : util.EqHashMap [Var , Refs ] = new util.EqHashMap
0 commit comments