@@ -93,8 +93,7 @@ sealed abstract class CaptureSet extends Showable:
93
93
def accountsFor (x : CaptureRef )(using ctx : Context ): Boolean =
94
94
reporting.trace(i " $this accountsFor $x, ${x.captureSetOfInfo}? " , show = true ) {
95
95
elems.contains(x)
96
- || ! x.isRootCapability
97
- && x.captureSetOfInfo.subCaptures(this , frozen = true ) == CompareResult .OK
96
+ || ! x.isRootCapability && x.captureSetOfInfo.subCaptures(this , frozen = true ).isOK
98
97
}
99
98
100
99
/** The subcapturing test */
@@ -105,9 +104,9 @@ sealed abstract class CaptureSet extends Showable:
105
104
def recur (elems : List [CaptureRef ]): CompareResult = elems match
106
105
case elem :: elems1 =>
107
106
var result = that.tryInclude(elem, this )
108
- if result != CompareResult . OK && ! elem.isRootCapability && summon[VarState ] != FrozenState then
107
+ if ! result.isOK && ! elem.isRootCapability && summon[VarState ] != FrozenState then
109
108
result = elem.captureSetOfInfo.subCaptures(that)
110
- if result == CompareResult . OK then
109
+ if result.isOK then
111
110
recur(elems1)
112
111
else
113
112
varState.abort()
@@ -118,15 +117,15 @@ sealed abstract class CaptureSet extends Showable:
118
117
.showing(i " subcaptures $this <:< $that = ${result.show}" , capt)
119
118
120
119
def =:= (that : CaptureSet )(using Context ): Boolean =
121
- this .subCaptures(that, frozen = true ) == CompareResult . OK
122
- && that.subCaptures(this , frozen = true ) == CompareResult . OK
120
+ this .subCaptures(that, frozen = true ).isOK
121
+ && that.subCaptures(this , frozen = true ).isOK
123
122
124
123
/** The smallest capture set (via <:<) that is a superset of both
125
124
* `this` and `that`
126
125
*/
127
126
def ++ (that : CaptureSet )(using Context ): CaptureSet =
128
- if this .subCaptures(that, frozen = true ) == CompareResult . OK then that
129
- else if that.subCaptures(this , frozen = true ) == CompareResult . OK then this
127
+ if this .subCaptures(that, frozen = true ).isOK then that
128
+ else if that.subCaptures(this , frozen = true ).isOK then this
130
129
else if this .isConst && that.isConst then Const (this .elems ++ that.elems)
131
130
else Var (this .elems ++ that.elems).addSub(this ).addSub(that)
132
131
@@ -138,8 +137,8 @@ sealed abstract class CaptureSet extends Showable:
138
137
/** The largest capture set (via <:<) that is a subset of both `this` and `that`
139
138
*/
140
139
def ** (that : CaptureSet )(using Context ): CaptureSet =
141
- if this .subCaptures(that, frozen = true ) == CompareResult . OK then this
142
- else if that.subCaptures(this , frozen = true ) == CompareResult . OK then that
140
+ if this .subCaptures(that, frozen = true ).isOK then this
141
+ else if that.subCaptures(this , frozen = true ).isOK then that
143
142
else if this .isConst && that.isConst then Const (elems.intersect(that.elems))
144
143
else if that.isConst then Intersected (this .asVar, that)
145
144
else Intersected (that.asVar, this )
@@ -273,7 +272,7 @@ object CaptureSet:
273
272
val depsIt = deps.iterator
274
273
while depsIt.hasNext do
275
274
val result = depsIt.next.tryInclude(newElems, this )
276
- if result != CompareResult . OK then return result
275
+ if ! result.isOK then return result
277
276
CompareResult .OK
278
277
else
279
278
CompareResult .fail(this )
@@ -306,8 +305,7 @@ object CaptureSet:
306
305
// println(i"solving var $this $approx ${approx.isConst} deps = ${deps.toList}")
307
306
if approx.isConst then
308
307
val newElems = approx.elems -- elems
309
- if newElems.isEmpty
310
- || addNewElems(newElems, empty)(using ctx, VarState ()) == CompareResult .OK then
308
+ if newElems.isEmpty || addNewElems(newElems, empty)(using ctx, VarState ()).isOK then
311
309
markSolved()
312
310
313
311
def markSolved ()(using Context ): Unit =
@@ -362,7 +360,7 @@ object CaptureSet:
362
360
return CompareResult .fail(this )
363
361
Const (newElems)
364
362
val result = super .addNewElems(added.elems, origin)
365
- if result == CompareResult . OK then
363
+ if result.isOK then
366
364
if added.isConst then result
367
365
else if added.asVar.recordDepsState() then { addSub(added); result }
368
366
else CompareResult .fail(this )
@@ -387,7 +385,7 @@ object CaptureSet:
387
385
super .addNewElems(newElems.map(bimap.forward), origin)
388
386
else
389
387
val r = super .addNewElems(newElems, origin)
390
- if r == CompareResult . OK then
388
+ if r.isOK then
391
389
source.tryInclude(newElems.map(bimap.backward), this )
392
390
.showing(i " propagating new elems $newElems backward from $this to $source" , capt)
393
391
else r
@@ -449,7 +447,7 @@ object CaptureSet:
449
447
extension (result : Type )
450
448
def isOK : Boolean = result eq OK
451
449
def blocking : CaptureSet = result
452
- def show : String = if result == OK then " OK" else result.toString
450
+ def show : String = if result.isOK then " OK" else result.toString
453
451
inline def andAlso (op : => Type ) = if result.isOK then op else result
454
452
455
453
class VarState :
0 commit comments