@@ -19,6 +19,7 @@ import Errors.*
19
19
import Trace .*
20
20
import Util .*
21
21
22
+ import scala .collection .immutable .ListSet
22
23
import scala .collection .mutable
23
24
import scala .annotation .tailrec
24
25
@@ -127,15 +128,15 @@ object Objects:
127
128
*
128
129
* It comes from `if` expressions.
129
130
*/
130
- case class RefSet (refs : List [Value ]) extends Value :
131
+ case class RefSet (refs : ListSet [Value ]) extends Value :
131
132
assert(refs.forall(! _.isInstanceOf [RefSet ]))
132
133
def show (using Context ) = refs.map(_.show).mkString(" [" , " ," , " ]" )
133
134
134
135
/** A cold alias which should not be used during initialization. */
135
136
case object Cold extends Value :
136
137
def show (using Context ) = " Cold"
137
138
138
- val Bottom = RefSet (Nil )
139
+ val Bottom = RefSet (ListSet .empty )
139
140
140
141
/** Checking state */
141
142
object State :
@@ -269,9 +270,9 @@ object Objects:
269
270
case (Bottom , b) => b
270
271
case (a, Bottom ) => a
271
272
case (RefSet (refs1), RefSet (refs2)) => RefSet (refs1 ++ refs2)
272
- case (a, RefSet (refs)) => RefSet (a :: refs )
273
- case (RefSet (refs), b) => RefSet (b :: refs )
274
- case (a, b) => RefSet (a :: b :: Nil )
273
+ case (a, RefSet (refs)) => RefSet (refs + a )
274
+ case (RefSet (refs), b) => RefSet (refs + b )
275
+ case (a, b) => RefSet (ListSet (a, b) )
275
276
276
277
def widen (height : Int )(using Context ): Value =
277
278
a match
@@ -294,7 +295,7 @@ object Objects:
294
295
case _ => a
295
296
296
297
297
- extension (values : Seq [Value ])
298
+ extension (values : Iterable [Value ])
298
299
def join : Value = if values.isEmpty then Bottom else values.reduce { (v1, v2) => v1.join(v2) }
299
300
300
301
def widen (height : Int ): Contextual [List [Value ]] = values.map(_.widen(height)).toList
0 commit comments