@@ -2216,7 +2216,7 @@ object Types {
2216
2216
abstract class TypeAccumulator [T ](implicit ctx : Context ) extends ((T , Type ) => T ) {
2217
2217
def apply (x : T , tp : Type ): T
2218
2218
2219
- protected def apply (x : T , annot : Annotation ): T = x // don't go into annotations
2219
+ protected def applyToAnnot (x : T , annot : Annotation ): T = x // don't go into annotations
2220
2220
2221
2221
protected var variance = 1
2222
2222
@@ -2237,7 +2237,7 @@ object Types {
2237
2237
2238
2238
case tp @ MethodType (pnames, ptypes) =>
2239
2239
variance = - variance
2240
- val y = (x /: ptypes)( this )
2240
+ val y = foldOver(x, ptypes)
2241
2241
variance = - variance
2242
2242
this (y, tp.resultType)
2243
2243
@@ -2246,7 +2246,7 @@ object Types {
2246
2246
2247
2247
case tp @ PolyType (pnames) =>
2248
2248
variance = - variance
2249
- val y = (x /: tp.paramBounds)( this )
2249
+ val y = foldOver(x, tp.paramBounds)
2250
2250
variance = - variance
2251
2251
this (y, tp.resultType)
2252
2252
@@ -2275,7 +2275,7 @@ object Types {
2275
2275
this (this (x, tp.tp1), tp.tp2)
2276
2276
2277
2277
case AnnotatedType (annot, underlying) =>
2278
- this (this (x, annot), underlying)
2278
+ this (applyToAnnot (x, annot), underlying)
2279
2279
2280
2280
case tp : TypeVar =>
2281
2281
this (x, tp.underlying)
@@ -2288,6 +2288,11 @@ object Types {
2288
2288
2289
2289
case _ => x
2290
2290
}
2291
+
2292
+ final def foldOver (x : T , ts : List [Type ]): T = ts match {
2293
+ case t :: ts1 => foldOver(apply(x, t), ts1)
2294
+ case nil => x
2295
+ }
2291
2296
}
2292
2297
2293
2298
class ExistsAccumulator (p : Type => Boolean )(implicit ctx : Context ) extends TypeAccumulator [Boolean ] {
0 commit comments