@@ -3840,14 +3840,26 @@ object Types extends TypeUtils {
3840
3840
* result in a [[NoDenotation ]], which would make later disambiguation of
3841
3841
* overloads impossible. See `tests/pos/annot-17242.scala` for example.
3842
3842
*/
3843
- private class IntegrateMap (params : List [Symbol ], paramRefs : List [Type ])(using Context ) extends TypeMap :
3843
+ private class IntegrateMap (from : List [Symbol ], to : List [Type ])(using Context ) extends TypeMap :
3844
3844
override def apply (tp : Type ) =
3845
+ // Same implementation as in `SubstMap`, except the `derivedSelect` in
3846
+ // the `NamedType` case, and the default case that just calls `mapOver`.
3845
3847
tp match
3846
- case tp : NamedType if params.contains(tp.symbol) => paramRefs(params.indexOf(tp.symbol))
3848
+ case tp : NamedType =>
3849
+ val sym = tp.symbol
3850
+ var fs = from
3851
+ var ts = to
3852
+ while (fs.nonEmpty && ts.nonEmpty) {
3853
+ if (fs.head eq sym) return ts.head
3854
+ fs = fs.tail
3855
+ ts = ts.tail
3856
+ }
3857
+ if (tp.prefix `eq` NoPrefix ) tp
3858
+ else derivedSelect(tp, apply(tp.prefix))
3847
3859
case _ : BoundType | _ : ThisType => tp
3848
3860
case _ => mapOver(tp)
3849
3861
3850
- override def derivedSelect (tp : NamedType , pre : Type ): Type =
3862
+ override final def derivedSelect (tp : NamedType , pre : Type ): Type =
3851
3863
if tp.prefix eq pre then tp
3852
3864
else if tp.symbol.exists then NamedType (pre, tp.name, tp.denot.asSeenFrom(pre))
3853
3865
else NamedType (pre, tp.name)
0 commit comments