Skip to content

Commit 9e1a411

Browse files
committed
Change defaults for NamedPartsAccumulator
- let it always stop at static - always include lower bounds The only occasiom where these defaults were reverted was when we computed implicit companion refs, but that's now done in its own function.
1 parent 757e431 commit 9e1a411

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,10 @@ object Types {
400400
* satisfy predicate `p`.
401401
*
402402
* @param p The predicate to satisfy
403-
* @param excludeLowerBounds If set to true, the lower bounds of abstract
404-
* types will be ignored.
405403
*/
406-
def namedPartsWith(p: NamedType => Boolean, excludeLowerBounds: Boolean = false)
404+
def namedPartsWith(p: NamedType => Boolean)
407405
(using Context): collection.Set[NamedType] =
408-
new NamedPartsAccumulator(p, excludeLowerBounds).apply(mutable.LinkedHashSet(), this)
406+
new NamedPartsAccumulator(p).apply(mutable.LinkedHashSet(), this)
409407

410408
/** Map function `f` over elements of an AndType, rebuilding with function `g` */
411409
def mapReduceAnd[T](f: Type => T)(g: (T, T) => T)(using Context): T = stripTypeVar match {
@@ -5520,9 +5518,8 @@ object Types {
55205518
override def hash(x: Type): Int = System.identityHashCode(x)
55215519
override def isEqual(x: Type, y: Type) = x.eq(y)
55225520

5523-
class NamedPartsAccumulator(p: NamedType => Boolean, excludeLowerBounds: Boolean = false)
5524-
(using Context) extends TypeAccumulator[mutable.Set[NamedType]] {
5525-
override def stopAtStatic: Boolean = false
5521+
class NamedPartsAccumulator(p: NamedType => Boolean)(using Context)
5522+
extends TypeAccumulator[mutable.Set[NamedType]] {
55265523
def maybeAdd(x: mutable.Set[NamedType], tp: NamedType): mutable.Set[NamedType] = if (p(tp)) x += tp else x
55275524
val seen = TypeHashSet()
55285525
def apply(x: mutable.Set[NamedType], tp: Type): mutable.Set[NamedType] =
@@ -5541,7 +5538,7 @@ object Types {
55415538
case tp: AppliedType =>
55425539
foldOver(x, tp)
55435540
case TypeBounds(lo, hi) =>
5544-
if (!excludeLowerBounds) apply(x, lo)
5541+
apply(x, lo)
55455542
apply(x, hi)
55465543
case tp: ParamRef =>
55475544
apply(x, tp.underlying)

0 commit comments

Comments
 (0)