Skip to content

Commit d8cd2bb

Browse files
committed
Convert to using clauses
1 parent 2229f59 commit d8cd2bb

File tree

6 files changed

+425
-425
lines changed

6 files changed

+425
-425
lines changed

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ object Contexts {
7878
*/
7979
abstract class Context(val base: ContextBase)
8080
extends Periods
81-
with Substituters
8281
with Phases
8382
with Printers
8483
with Symbols

compiler/src/dotty/tools/dotc/core/Substituters.scala

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import Types._, Symbols._, Contexts._
55
/** Substitution operations on types. See the corresponding `subst` and
66
* `substThis` methods on class Type for an explanation.
77
*/
8-
trait Substituters { this: Context =>
8+
object Substituters:
99

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 =
1111
tp match {
1212
case tp: BoundType =>
1313
if (tp.binder eq from) tp.copyBoundType(to.asInstanceOf[tp.BT]) else tp
@@ -21,7 +21,7 @@ trait Substituters { this: Context =>
2121
.mapOver(tp)
2222
}
2323

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 =
2525
tp match {
2626
case tp: NamedType =>
2727
val sym = tp.symbol
@@ -35,7 +35,7 @@ trait Substituters { this: Context =>
3535
.mapOver(tp)
3636
}
3737

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 =
3939
tp match {
4040
case tp: NamedType =>
4141
val sym = tp.symbol
@@ -50,7 +50,7 @@ trait Substituters { this: Context =>
5050
.mapOver(tp)
5151
}
5252

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 =
5454
tp match {
5555
case tp: NamedType =>
5656
val sym = tp.symbol
@@ -70,7 +70,7 @@ trait Substituters { this: Context =>
7070
.mapOver(tp)
7171
}
7272

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 =
7474
tp match {
7575
case tp: NamedType =>
7676
val sym = tp.symbol
@@ -101,7 +101,7 @@ trait Substituters { this: Context =>
101101
.mapOver(tp)
102102
}
103103

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 =
105105
tp match {
106106
case tp: ThisType =>
107107
if (tp.cls eq from) to else tp
@@ -115,7 +115,7 @@ trait Substituters { this: Context =>
115115
.mapOver(tp)
116116
}
117117

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 =
119119
tp match {
120120
case tp @ RecThis(binder) =>
121121
if (binder eq from) to else tp
@@ -129,7 +129,7 @@ trait Substituters { this: Context =>
129129
.mapOver(tp)
130130
}
131131

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 =
133133
tp match {
134134
case tp: BoundType =>
135135
if (tp == from) to else tp
@@ -143,7 +143,7 @@ trait Substituters { this: Context =>
143143
.mapOver(tp)
144144
}
145145

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 =
147147
tp match {
148148
case tp: ParamRef =>
149149
if (tp.binder == from) to(tp.paramNum) else tp
@@ -157,44 +157,44 @@ trait Substituters { this: Context =>
157157
.mapOver(tp)
158158
}
159159

160-
final class SubstBindingMap(from: BindingType, to: BindingType) extends DeepTypeMap {
160+
final class SubstBindingMap(from: BindingType, to: BindingType)(using Context) extends DeepTypeMap {
161161
def apply(tp: Type): Type = subst(tp, from, to, this)
162162
}
163163

164-
final class Subst1Map(from: Symbol, to: Type) extends DeepTypeMap {
164+
final class Subst1Map(from: Symbol, to: Type)(using Context) extends DeepTypeMap {
165165
def apply(tp: Type): Type = subst1(tp, from, to, this)
166166
}
167167

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 {
169169
def apply(tp: Type): Type = subst2(tp, from1, to1, from2, to2, this)
170170
}
171171

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 {
173173
def apply(tp: Type): Type = subst(tp, from, to, this)
174174
}
175175

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 {
177177
def apply(tp: Type): Type = substSym(tp, from, to, this)
178178
}
179179

180-
final class SubstThisMap(from: ClassSymbol, to: Type) extends DeepTypeMap {
180+
final class SubstThisMap(from: ClassSymbol, to: Type)(using Context) extends DeepTypeMap {
181181
def apply(tp: Type): Type = substThis(tp, from, to, this)
182182
}
183183

184-
final class SubstRecThisMap(from: Type, to: Type) extends DeepTypeMap {
184+
final class SubstRecThisMap(from: Type, to: Type)(using Context) extends DeepTypeMap {
185185
def apply(tp: Type): Type = substRecThis(tp, from, to, this)
186186
}
187187

188-
final class SubstParamMap(from: ParamRef, to: Type) extends DeepTypeMap {
188+
final class SubstParamMap(from: ParamRef, to: Type)(using Context) extends DeepTypeMap {
189189
def apply(tp: Type): Type = substParam(tp, from, to, this)
190190
}
191191

192-
final class SubstParamsMap(from: BindingType, to: List[Type]) extends DeepTypeMap {
192+
final class SubstParamsMap(from: BindingType, to: List[Type])(using Context) extends DeepTypeMap {
193193
def apply(tp: Type): Type = substParams(tp, from, to, this)
194194
}
195195

196196
/** 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 {
198198
def apply(tp: Type): Type = tp match {
199199
case tp: NamedType =>
200200
val sym = tp.symbol
@@ -216,4 +216,4 @@ trait Substituters { this: Context =>
216216
mapOver(tp)
217217
}
218218
}
219-
}
219+
end Substituters

compiler/src/dotty/tools/dotc/core/TypeApplications.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ class TypeApplications(val self: Type) extends AnyVal {
337337
case dealiased: TypeBounds =>
338338
dealiased.derivedTypeBounds(dealiased.lo.appliedTo(args), dealiased.hi.appliedTo(args))
339339
case dealiased: LazyRef =>
340-
LazyRef(c => dealiased.ref(c).appliedTo(args)(using c))
340+
LazyRef(c => dealiased.ref(using c).appliedTo(args)(using c))
341341
case dealiased: WildcardType =>
342342
WildcardType(dealiased.optBounds.orElse(TypeBounds.empty).appliedTo(args).bounds)
343343
case dealiased: TypeRef if dealiased.symbol == defn.NothingClass =>

0 commit comments

Comments
 (0)