11package dotty .tools .dotc .core
22
3- import Types ._ , Symbols ._ , Contexts ._
3+ import Types ._ , Symbols ._ , Contexts ._ , Decorators . _
44
55/** Substitution operations on types. See the corresponding `subst` and
66 * `substThis` methods on class Type for an explanation.
@@ -16,6 +16,8 @@ object Substituters:
1616 else tp.derivedSelect(subst(tp.prefix, from, to, theMap))
1717 case _ : ThisType =>
1818 tp
19+ case tp : AppliedType =>
20+ tp.map(subst(_, from, to, theMap))
1921 case _ =>
2022 (if (theMap != null ) theMap else new SubstBindingMap (from, to))
2123 .mapOver(tp)
@@ -94,7 +96,7 @@ object Substituters:
9496 ts = ts.tail
9597 }
9698 tp
97- case _ : ThisType | _ : BoundType =>
99+ case _ : BoundType =>
98100 tp
99101 case _ =>
100102 (if (theMap != null ) theMap else new SubstSymMap (from, to))
@@ -152,45 +154,47 @@ object Substituters:
152154 else tp.derivedSelect(substParams(tp.prefix, from, to, theMap))
153155 case _ : ThisType =>
154156 tp
157+ case tp : AppliedType =>
158+ tp.map(substParams(_, from, to, theMap))
155159 case _ =>
156160 (if (theMap != null ) theMap else new SubstParamsMap (from, to))
157161 .mapOver(tp)
158162 }
159163
160164 final class SubstBindingMap (from : BindingType , to : BindingType )(using Context ) extends DeepTypeMap {
161- def apply (tp : Type ): Type = subst(tp, from, to, this )
165+ def apply (tp : Type ): Type = subst(tp, from, to, this )( using mapCtx)
162166 }
163167
164168 final class Subst1Map (from : Symbol , to : Type )(using Context ) extends DeepTypeMap {
165- def apply (tp : Type ): Type = subst1(tp, from, to, this )
169+ def apply (tp : Type ): Type = subst1(tp, from, to, this )( using mapCtx)
166170 }
167171
168172 final class Subst2Map (from1 : Symbol , to1 : Type , from2 : Symbol , to2 : Type )(using Context ) extends DeepTypeMap {
169- def apply (tp : Type ): Type = subst2(tp, from1, to1, from2, to2, this )
173+ def apply (tp : Type ): Type = subst2(tp, from1, to1, from2, to2, this )( using mapCtx)
170174 }
171175
172176 final class SubstMap (from : List [Symbol ], to : List [Type ])(using Context ) extends DeepTypeMap {
173- def apply (tp : Type ): Type = subst(tp, from, to, this )
177+ def apply (tp : Type ): Type = subst(tp, from, to, this )( using mapCtx)
174178 }
175179
176180 final class SubstSymMap (from : List [Symbol ], to : List [Symbol ])(using Context ) extends DeepTypeMap {
177- def apply (tp : Type ): Type = substSym(tp, from, to, this )
181+ def apply (tp : Type ): Type = substSym(tp, from, to, this )( using mapCtx)
178182 }
179183
180184 final class SubstThisMap (from : ClassSymbol , to : Type )(using Context ) extends DeepTypeMap {
181- def apply (tp : Type ): Type = substThis(tp, from, to, this )
185+ def apply (tp : Type ): Type = substThis(tp, from, to, this )( using mapCtx)
182186 }
183187
184188 final class SubstRecThisMap (from : Type , to : Type )(using Context ) extends DeepTypeMap {
185- def apply (tp : Type ): Type = substRecThis(tp, from, to, this )
189+ def apply (tp : Type ): Type = substRecThis(tp, from, to, this )( using mapCtx)
186190 }
187191
188192 final class SubstParamMap (from : ParamRef , to : Type )(using Context ) extends DeepTypeMap {
189- def apply (tp : Type ): Type = substParam(tp, from, to, this )
193+ def apply (tp : Type ): Type = substParam(tp, from, to, this )( using mapCtx)
190194 }
191195
192196 final class SubstParamsMap (from : BindingType , to : List [Type ])(using Context ) extends DeepTypeMap {
193- def apply (tp : Type ): Type = substParams(tp, from, to, this )
197+ def apply (tp : Type ): Type = substParams(tp, from, to, this )( using mapCtx)
194198 }
195199
196200 /** An approximating substitution that can handle wildcards in the `to` list */
0 commit comments