Skip to content

Commit 60dec6d

Browse files
committed
Eliminate ParamType
Replace with ParamRef
1 parent 2af5d8d commit 60dec6d

File tree

5 files changed

+12
-18
lines changed

5 files changed

+12
-18
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ trait Substituters { this: Context =>
196196
.mapOver(tp)
197197
}
198198

199-
final def substParam(tp: Type, from: ParamType, to: Type, theMap: SubstParamMap): Type =
199+
final def substParam(tp: Type, from: ParamRef, to: Type, theMap: SubstParamMap): Type =
200200
tp match {
201201
case tp: BoundType =>
202202
if (tp == from) to else tp
@@ -216,7 +216,7 @@ trait Substituters { this: Context =>
216216

217217
final def substParams(tp: Type, from: BindingType, to: List[Type], theMap: SubstParamsMap): Type =
218218
tp match {
219-
case tp: ParamType =>
219+
case tp: ParamRef =>
220220
if (tp.binder == from) to(tp.paramNum) else tp
221221
case tp: NamedType =>
222222
if (tp.currentSymbol.isStatic) tp
@@ -269,7 +269,7 @@ trait Substituters { this: Context =>
269269
def apply(tp: Type): Type = substRecThis(tp, from, to, this)
270270
}
271271

272-
final class SubstParamMap(from: ParamType, to: Type) extends DeepTypeMap {
272+
final class SubstParamMap(from: ParamRef, to: Type) extends DeepTypeMap {
273273
def apply(tp: Type) = substParam(tp, from, to, this)
274274
}
275275

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ object Types {
11991199
ctx.substRecThis(this, binder, tp, null)
12001200

12011201
/** Substitute a bound type by some other type */
1202-
final def substParam(from: ParamType, to: Type)(implicit ctx: Context): Type =
1202+
final def substParam(from: ParamRef, to: Type)(implicit ctx: Context): Type =
12031203
ctx.substParam(this, from, to, null)
12041204

12051205
/** Substitute bound types by some other types */
@@ -2407,8 +2407,6 @@ object Types {
24072407
type PInfo = Type
24082408
type This <: TermLambda
24092409

2410-
def paramNames: List[TermName]
2411-
24122410
override def resultType(implicit ctx: Context): Type =
24132411
if (dependencyStatus == FalseDeps) { // dealias all false dependencies
24142412
val dealiasMap = new TypeMap {
@@ -2827,21 +2825,17 @@ object Types {
28272825
unique(new CachedHKApply(tycon, args)).checkInst
28282826
}
28292827

2830-
// ----- Bound types: MethodParam, TypeParamRef --------------------------
2828+
// ----- BoundTypes: ParamRef, RecThis ----------------------------------------
28312829

28322830
abstract class BoundType extends CachedProxyType with ValueType {
28332831
type BT <: Type
28342832
val binder: BT
28352833
def copyBoundType(bt: BT): Type
28362834
}
28372835

2838-
abstract class ParamType extends BoundType {
2839-
def paramNum: Int
2840-
def paramName: Name
2841-
}
2842-
2843-
abstract class ParamRef extends ParamType {
2836+
abstract class ParamRef extends BoundType {
28442837
type BT <: LambdaType
2838+
def paramNum: Int
28452839
def paramName: binder.ThisName = binder.paramNames(paramNum)
28462840

28472841
override def underlying(implicit ctx: Context): Type = {

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,14 @@ class TreePickler(pickler: TastyPickler) {
260260
writeByte(METHODtype)
261261
pickleMethodic(tpe.resultType, tpe.paramNames, tpe.paramInfos)
262262
case tpe: TypeParamRef =>
263-
if (!pickleParamType(tpe))
263+
if (!pickleParamRef(tpe))
264264
// TODO figure out why this case arises in e.g. pickling AbstractFileReader.
265265
ctx.typerState.constraint.entry(tpe) match {
266266
case TypeBounds(lo, hi) if lo eq hi => pickleNewType(lo, richTypes)
267267
case _ => assert(false, s"orphan poly parameter: $tpe")
268268
}
269269
case tpe: TermParamRef =>
270-
assert(pickleParamType(tpe), s"orphan method parameter: $tpe")
270+
assert(pickleParamRef(tpe), s"orphan method parameter: $tpe")
271271
case tpe: LazyRef =>
272272
pickleType(tpe.ref)
273273
}} catch {
@@ -289,7 +289,7 @@ class TreePickler(pickler: TastyPickler) {
289289
}
290290
}
291291

292-
def pickleParamType(tpe: ParamType)(implicit ctx: Context): Boolean = {
292+
def pickleParamRef(tpe: ParamRef)(implicit ctx: Context): Boolean = {
293293
val binder = pickledTypes.get(tpe.binder)
294294
val pickled = binder != null
295295
if (pickled) {

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
424424
new api.Annotated(apiType(tpe), Array(apiAnnotation(annot)))
425425
case tp: ThisType =>
426426
apiThis(tp.cls)
427-
case tp: ParamType =>
427+
case tp: ParamRef =>
428428
// TODO: Distinguishing parameters based on their names alone is not enough,
429429
// the binder is also needed (at least for type lambdas).
430430
new api.ParameterRef(tp.paramName.toString)

compiler/src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class TreeChecker extends Phase with SymTransformer {
296296
definedBinders += tp
297297
mapOver(tp)
298298
definedBinders -= tp
299-
case tp: ParamType =>
299+
case tp: ParamRef =>
300300
assert(definedBinders.contains(tp.binder), s"orphan param: $tp")
301301
case tp: TypeVar =>
302302
apply(tp.underlying)

0 commit comments

Comments
 (0)