1
1
package dotty .tools .dotc .core
2
2
3
- import Types ._ , Symbols ._ , Contexts ._
3
+ import Types ._ , Symbols ._ , Contexts ._ , Decorators . _
4
4
5
5
/** Substitution operations on types. See the corresponding `subst` and
6
6
* `substThis` methods on class Type for an explanation.
@@ -16,6 +16,8 @@ object Substituters:
16
16
else tp.derivedSelect(subst(tp.prefix, from, to, theMap))
17
17
case _ : ThisType =>
18
18
tp
19
+ case tp : AppliedType =>
20
+ tp.map(subst(_, from, to, theMap))
19
21
case _ =>
20
22
(if (theMap != null ) theMap else new SubstBindingMap (from, to))
21
23
.mapOver(tp)
@@ -94,7 +96,7 @@ object Substituters:
94
96
ts = ts.tail
95
97
}
96
98
tp
97
- case _ : ThisType | _ : BoundType =>
99
+ case _ : BoundType =>
98
100
tp
99
101
case _ =>
100
102
(if (theMap != null ) theMap else new SubstSymMap (from, to))
@@ -152,45 +154,47 @@ object Substituters:
152
154
else tp.derivedSelect(substParams(tp.prefix, from, to, theMap))
153
155
case _ : ThisType =>
154
156
tp
157
+ case tp : AppliedType =>
158
+ tp.map(substParams(_, from, to, theMap))
155
159
case _ =>
156
160
(if (theMap != null ) theMap else new SubstParamsMap (from, to))
157
161
.mapOver(tp)
158
162
}
159
163
160
164
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)
162
166
}
163
167
164
168
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)
166
170
}
167
171
168
172
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)
170
174
}
171
175
172
176
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)
174
178
}
175
179
176
180
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)
178
182
}
179
183
180
184
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)
182
186
}
183
187
184
188
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)
186
190
}
187
191
188
192
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)
190
194
}
191
195
192
196
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)
194
198
}
195
199
196
200
/** An approximating substitution that can handle wildcards in the `to` list */
0 commit comments