diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 51fe1a3d1f18..697b27671fc5 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -3475,28 +3475,26 @@ object Types { */ private def gatherTreeUniqueMembersAbsorbingNothingTypes(using Context): MutableSet[Type] = { - var trees = List(this) + var unvisitedSubtrees = List(this) val uniqueTreeMembers = new EqLinkedHashSet[Type] - while (trees.nonEmpty) { - trees match { + while (unvisitedSubtrees.nonEmpty) { + unvisitedSubtrees match case head :: tail => - head match { + head match case OrType(l: OrType, r: OrType) => - trees = l :: r :: tail + unvisitedSubtrees = l :: r :: tail case OrType(l, r: OrType) => - trees = r :: tail + unvisitedSubtrees = r :: tail if !l.isNothingType then uniqueTreeMembers += l case OrType(l: OrType, r) => - trees = l :: tail + unvisitedSubtrees = l :: tail if !r.isNothingType then uniqueTreeMembers += r case OrType(l, r) => - trees = tail + unvisitedSubtrees = tail uniqueTreeMembers += l if !r.isNothingType then uniqueTreeMembers += r - } case _ => - } } uniqueTreeMembers diff --git a/compiler/src/dotty/tools/dotc/util/EqLinkedHashSet.scala b/compiler/src/dotty/tools/dotc/util/EqLinkedHashSet.scala index 73124d106ca6..1afd562a518b 100644 --- a/compiler/src/dotty/tools/dotc/util/EqLinkedHashSet.scala +++ b/compiler/src/dotty/tools/dotc/util/EqLinkedHashSet.scala @@ -32,15 +32,3 @@ class EqLinkedHashSet[T]( override def iterator: Iterator[T] = linkingArray.iterator } - -object EqLinkedHashSet { - def apply[T](x: T): EqLinkedHashSet[T] = - val set = new EqLinkedHashSet[T] - set += x - set - - def apply[T](x: T, y: T): EqLinkedHashSet[T] = - val set = EqLinkedHashSet(x) - set += y - set -}