@@ -3747,14 +3747,26 @@ object Types extends TypeUtils {
37473747 * result in a [[NoDenotation ]], which would make later disambiguation of
37483748 * overloads impossible. See `tests/pos/annot-17242.scala` for example.
37493749 */
3750- private class IntegrateMap (params : List [Symbol ], paramRefs : List [Type ])(using Context ) extends TypeMap :
3750+ private class IntegrateMap (from : List [Symbol ], to : List [Type ])(using Context ) extends TypeMap :
37513751 override def apply (tp : Type ) =
3752+ // Same implementation as in `SubstMap`, except the `derivedSelect` in
3753+ // the `NamedType` case, and the default case that just calls `mapOver`.
37523754 tp match
3753- case tp : NamedType if params.contains(tp.symbol) => paramRefs(params.indexOf(tp.symbol))
3755+ case tp : NamedType =>
3756+ val sym = tp.symbol
3757+ var fs = from
3758+ var ts = to
3759+ while (fs.nonEmpty && ts.nonEmpty) {
3760+ if (fs.head eq sym) return ts.head
3761+ fs = fs.tail
3762+ ts = ts.tail
3763+ }
3764+ if (tp.prefix `eq` NoPrefix ) tp
3765+ else derivedSelect(tp, apply(tp.prefix))
37543766 case _ : BoundType | _ : ThisType => tp
37553767 case _ => mapOver(tp)
37563768
3757- override def derivedSelect (tp : NamedType , pre : Type ): Type =
3769+ override final def derivedSelect (tp : NamedType , pre : Type ): Type =
37583770 if tp.prefix eq pre then tp
37593771 else if tp.symbol.exists then NamedType (pre, tp.name, tp.denot.asSeenFrom(pre))
37603772 else NamedType (pre, tp.name)
0 commit comments