@@ -239,9 +239,14 @@ object Types {
239
239
240
240
/** The parts of this type which are type or term refs and which
241
241
* satisfy predicate `p`.
242
+ *
243
+ * @param p The predicate to satisfy
244
+ * @param excludeLowerBounds If set to true, the lower bounds of abstract
245
+ * types will be ignored.
242
246
*/
243
- def namedPartsWith (p : NamedType => Boolean )(implicit ctx : Context ): collection.Set [NamedType ] =
244
- new NamedPartsAccumulator (p).apply(mutable.LinkedHashSet (), this )
247
+ def namedPartsWith (p : NamedType => Boolean , excludeLowerBounds : Boolean = false )
248
+ (implicit ctx : Context ): collection.Set [NamedType ] =
249
+ new NamedPartsAccumulator (p, excludeLowerBounds).apply(mutable.LinkedHashSet (), this )
245
250
246
251
/** Map function `f` over elements of an AndType, rebuilding with function `g` */
247
252
def mapReduceAnd [T ](f : Type => T )(g : (T , T ) => T )(implicit ctx : Context ): T = stripTypeVar match {
@@ -3710,7 +3715,8 @@ object Types {
3710
3715
def apply (x : Boolean , tp : Type ) = x || tp.isUnsafeNonvariant || foldOver(x, tp)
3711
3716
}
3712
3717
3713
- class NamedPartsAccumulator (p : NamedType => Boolean )(implicit ctx : Context ) extends TypeAccumulator [mutable.Set [NamedType ]] {
3718
+ class NamedPartsAccumulator (p : NamedType => Boolean , excludeLowerBounds : Boolean = false )
3719
+ (implicit ctx : Context ) extends TypeAccumulator [mutable.Set [NamedType ]] {
3714
3720
override def stopAtStatic = false
3715
3721
def maybeAdd (x : mutable.Set [NamedType ], tp : NamedType ) = if (p(tp)) x += tp else x
3716
3722
val seen : mutable.Set [Type ] = mutable.Set ()
@@ -3723,7 +3729,8 @@ object Types {
3723
3729
apply(foldOver(maybeAdd(x, tp), tp), tp.underlying)
3724
3730
case tp : TypeRef =>
3725
3731
foldOver(maybeAdd(x, tp), tp)
3726
- case TypeBounds (_, hi) =>
3732
+ case TypeBounds (lo, hi) =>
3733
+ if (! excludeLowerBounds) apply(x, lo)
3727
3734
apply(x, hi)
3728
3735
case tp : ThisType =>
3729
3736
apply(x, tp.tref)
0 commit comments