@@ -5,9 +5,9 @@ import Types._, Symbols._, Contexts._
5
5
/** Substitution operations on types. See the corresponding `subst` and
6
6
* `substThis` methods on class Type for an explanation.
7
7
*/
8
- trait Substituters { this : Context =>
8
+ object Substituters :
9
9
10
- final def subst (tp : Type , from : BindingType , to : BindingType , theMap : SubstBindingMap ): Type =
10
+ final def subst (tp : Type , from : BindingType , to : BindingType , theMap : SubstBindingMap )( using Context ) : Type =
11
11
tp match {
12
12
case tp : BoundType =>
13
13
if (tp.binder eq from) tp.copyBoundType(to.asInstanceOf [tp.BT ]) else tp
@@ -21,7 +21,7 @@ trait Substituters { this: Context =>
21
21
.mapOver(tp)
22
22
}
23
23
24
- final def subst1 (tp : Type , from : Symbol , to : Type , theMap : Subst1Map ): Type =
24
+ final def subst1 (tp : Type , from : Symbol , to : Type , theMap : Subst1Map )( using Context ) : Type =
25
25
tp match {
26
26
case tp : NamedType =>
27
27
val sym = tp.symbol
@@ -35,7 +35,7 @@ trait Substituters { this: Context =>
35
35
.mapOver(tp)
36
36
}
37
37
38
- final def subst2 (tp : Type , from1 : Symbol , to1 : Type , from2 : Symbol , to2 : Type , theMap : Subst2Map ): Type =
38
+ final def subst2 (tp : Type , from1 : Symbol , to1 : Type , from2 : Symbol , to2 : Type , theMap : Subst2Map )( using Context ) : Type =
39
39
tp match {
40
40
case tp : NamedType =>
41
41
val sym = tp.symbol
@@ -50,7 +50,7 @@ trait Substituters { this: Context =>
50
50
.mapOver(tp)
51
51
}
52
52
53
- final def subst (tp : Type , from : List [Symbol ], to : List [Type ], theMap : SubstMap ): Type =
53
+ final def subst (tp : Type , from : List [Symbol ], to : List [Type ], theMap : SubstMap )( using Context ) : Type =
54
54
tp match {
55
55
case tp : NamedType =>
56
56
val sym = tp.symbol
@@ -70,7 +70,7 @@ trait Substituters { this: Context =>
70
70
.mapOver(tp)
71
71
}
72
72
73
- final def substSym (tp : Type , from : List [Symbol ], to : List [Symbol ], theMap : SubstSymMap ): Type =
73
+ final def substSym (tp : Type , from : List [Symbol ], to : List [Symbol ], theMap : SubstSymMap )( using Context ) : Type =
74
74
tp match {
75
75
case tp : NamedType =>
76
76
val sym = tp.symbol
@@ -101,7 +101,7 @@ trait Substituters { this: Context =>
101
101
.mapOver(tp)
102
102
}
103
103
104
- final def substThis (tp : Type , from : ClassSymbol , to : Type , theMap : SubstThisMap ): Type =
104
+ final def substThis (tp : Type , from : ClassSymbol , to : Type , theMap : SubstThisMap )( using Context ) : Type =
105
105
tp match {
106
106
case tp : ThisType =>
107
107
if (tp.cls eq from) to else tp
@@ -115,7 +115,7 @@ trait Substituters { this: Context =>
115
115
.mapOver(tp)
116
116
}
117
117
118
- final def substRecThis (tp : Type , from : Type , to : Type , theMap : SubstRecThisMap ): Type =
118
+ final def substRecThis (tp : Type , from : Type , to : Type , theMap : SubstRecThisMap )( using Context ) : Type =
119
119
tp match {
120
120
case tp @ RecThis (binder) =>
121
121
if (binder eq from) to else tp
@@ -129,7 +129,7 @@ trait Substituters { this: Context =>
129
129
.mapOver(tp)
130
130
}
131
131
132
- final def substParam (tp : Type , from : ParamRef , to : Type , theMap : SubstParamMap ): Type =
132
+ final def substParam (tp : Type , from : ParamRef , to : Type , theMap : SubstParamMap )( using Context ) : Type =
133
133
tp match {
134
134
case tp : BoundType =>
135
135
if (tp == from) to else tp
@@ -143,7 +143,7 @@ trait Substituters { this: Context =>
143
143
.mapOver(tp)
144
144
}
145
145
146
- final def substParams (tp : Type , from : BindingType , to : List [Type ], theMap : SubstParamsMap ): Type =
146
+ final def substParams (tp : Type , from : BindingType , to : List [Type ], theMap : SubstParamsMap )( using Context ) : Type =
147
147
tp match {
148
148
case tp : ParamRef =>
149
149
if (tp.binder == from) to(tp.paramNum) else tp
@@ -157,44 +157,44 @@ trait Substituters { this: Context =>
157
157
.mapOver(tp)
158
158
}
159
159
160
- final class SubstBindingMap (from : BindingType , to : BindingType ) extends DeepTypeMap {
160
+ final class SubstBindingMap (from : BindingType , to : BindingType )( using Context ) extends DeepTypeMap {
161
161
def apply (tp : Type ): Type = subst(tp, from, to, this )
162
162
}
163
163
164
- final class Subst1Map (from : Symbol , to : Type ) extends DeepTypeMap {
164
+ final class Subst1Map (from : Symbol , to : Type )( using Context ) extends DeepTypeMap {
165
165
def apply (tp : Type ): Type = subst1(tp, from, to, this )
166
166
}
167
167
168
- final class Subst2Map (from1 : Symbol , to1 : Type , from2 : Symbol , to2 : Type ) extends DeepTypeMap {
168
+ final class Subst2Map (from1 : Symbol , to1 : Type , from2 : Symbol , to2 : Type )( using Context ) extends DeepTypeMap {
169
169
def apply (tp : Type ): Type = subst2(tp, from1, to1, from2, to2, this )
170
170
}
171
171
172
- final class SubstMap (from : List [Symbol ], to : List [Type ]) extends DeepTypeMap {
172
+ final class SubstMap (from : List [Symbol ], to : List [Type ])( using Context ) extends DeepTypeMap {
173
173
def apply (tp : Type ): Type = subst(tp, from, to, this )
174
174
}
175
175
176
- final class SubstSymMap (from : List [Symbol ], to : List [Symbol ]) extends DeepTypeMap {
176
+ final class SubstSymMap (from : List [Symbol ], to : List [Symbol ])( using Context ) extends DeepTypeMap {
177
177
def apply (tp : Type ): Type = substSym(tp, from, to, this )
178
178
}
179
179
180
- final class SubstThisMap (from : ClassSymbol , to : Type ) extends DeepTypeMap {
180
+ final class SubstThisMap (from : ClassSymbol , to : Type )( using Context ) extends DeepTypeMap {
181
181
def apply (tp : Type ): Type = substThis(tp, from, to, this )
182
182
}
183
183
184
- final class SubstRecThisMap (from : Type , to : Type ) extends DeepTypeMap {
184
+ final class SubstRecThisMap (from : Type , to : Type )( using Context ) extends DeepTypeMap {
185
185
def apply (tp : Type ): Type = substRecThis(tp, from, to, this )
186
186
}
187
187
188
- final class SubstParamMap (from : ParamRef , to : Type ) extends DeepTypeMap {
188
+ final class SubstParamMap (from : ParamRef , to : Type )( using Context ) extends DeepTypeMap {
189
189
def apply (tp : Type ): Type = substParam(tp, from, to, this )
190
190
}
191
191
192
- final class SubstParamsMap (from : BindingType , to : List [Type ]) extends DeepTypeMap {
192
+ final class SubstParamsMap (from : BindingType , to : List [Type ])( using Context ) extends DeepTypeMap {
193
193
def apply (tp : Type ): Type = substParams(tp, from, to, this )
194
194
}
195
195
196
196
/** An approximating substitution that can handle wildcards in the `to` list */
197
- final class SubstApproxMap (from : List [Symbol ], to : List [Type ])(implicit ctx : Context ) extends ApproximatingTypeMap {
197
+ final class SubstApproxMap (from : List [Symbol ], to : List [Type ])(using Context ) extends ApproximatingTypeMap {
198
198
def apply (tp : Type ): Type = tp match {
199
199
case tp : NamedType =>
200
200
val sym = tp.symbol
@@ -216,4 +216,4 @@ trait Substituters { this: Context =>
216
216
mapOver(tp)
217
217
}
218
218
}
219
- }
219
+ end Substituters
0 commit comments