@@ -3747,14 +3747,26 @@ object Types extends TypeUtils {
3747
3747
* result in a [[NoDenotation ]], which would make later disambiguation of
3748
3748
* overloads impossible. See `tests/pos/annot-17242.scala` for example.
3749
3749
*/
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 :
3751
3751
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`.
3752
3754
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))
3754
3766
case _ : BoundType | _ : ThisType => tp
3755
3767
case _ => mapOver(tp)
3756
3768
3757
- override def derivedSelect (tp : NamedType , pre : Type ): Type =
3769
+ override final def derivedSelect (tp : NamedType , pre : Type ): Type =
3758
3770
if tp.prefix eq pre then tp
3759
3771
else if tp.symbol.exists then NamedType (pre, tp.name, tp.denot.asSeenFrom(pre))
3760
3772
else NamedType (pre, tp.name)
0 commit comments