Skip to content

Commit c63623f

Browse files
authored
Merge pull request #4243 from dotty-staging/remove/substDealias
Remove substDealias
2 parents c5ef4eb + 487c511 commit c63623f

File tree

4 files changed

+4
-50
lines changed

4 files changed

+4
-50
lines changed

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

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -73,35 +73,6 @@ trait Substituters { this: Context =>
7373
}
7474
}
7575

76-
final def substDealias(tp: Type, from: List[Symbol], to: List[Type], theMap: SubstDealiasMap): Type = {
77-
tp match {
78-
case tp: NamedType =>
79-
val sym = tp.symbol
80-
var fs = from
81-
var ts = to
82-
while (fs.nonEmpty) {
83-
if (fs.head eq sym) return ts.head
84-
fs = fs.tail
85-
ts = ts.tail
86-
}
87-
if (sym.isStatic && !existsStatic(from) || (tp.prefix `eq` NoPrefix)) tp
88-
else {
89-
tp.info match {
90-
case TypeAlias(alias) =>
91-
val alias1 = substDealias(alias, from, to, theMap)
92-
if (alias1 ne alias) return alias1
93-
case _ =>
94-
}
95-
tp.derivedSelect(substDealias(tp.prefix, from, to, theMap))
96-
}
97-
case _: ThisType | _: BoundType =>
98-
tp
99-
case _ =>
100-
(if (theMap != null) theMap else new SubstDealiasMap(from, to))
101-
.mapOver(tp)
102-
}
103-
}
104-
10576
final def substSym(tp: Type, from: List[Symbol], to: List[Symbol], theMap: SubstSymMap): Type =
10677
tp match {
10778
case tp: NamedType =>
@@ -210,10 +181,6 @@ trait Substituters { this: Context =>
210181
def apply(tp: Type): Type = subst(tp, from, to, this)
211182
}
212183

213-
final class SubstDealiasMap(from: List[Symbol], to: List[Type]) extends DeepTypeMap {
214-
override def apply(tp: Type): Type = substDealias(tp, from, to, this)
215-
}
216-
217184
final class SubstSymMap(from: List[Symbol], to: List[Symbol]) extends DeepTypeMap {
218185
def apply(tp: Type): Type = substSym(tp, from, to, this)
219186
}

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,17 +1322,6 @@ object Types {
13221322
}
13231323
}
13241324

1325-
/** Same as `subst` but follows aliases as a fallback. When faced with a reference
1326-
* to an alias type, where normal substitution does not yield a new type, the
1327-
* substitution is instead applied to the alias. If that yields a new type,
1328-
* this type is returned, otherwise the original type (not the alias) is returned.
1329-
* A use case for this method is if one wants to substitute the type parameters
1330-
* of a class and also wants to substitute any parameter accessors that alias
1331-
* the type parameters.
1332-
*/
1333-
final def substDealias(from: List[Symbol], to: List[Type])(implicit ctx: Context): Type =
1334-
ctx.substDealias(this, from, to, null)
1335-
13361325
/** Substitute all types of the form `TypeParamRef(from, N)` by
13371326
* `TypeParamRef(to, N)`.
13381327
*/

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ trait FullParameterization {
113113
/** Replace class type parameters by the added type parameters of the polytype `pt` */
114114
def mapClassParams(tp: Type, pt: PolyType): Type = {
115115
val classParamsRange = (mtparamCount until mtparamCount + ctparams.length).toList
116-
tp.substDealias(ctparams, classParamsRange map (pt.paramRefs(_)))
116+
tp.subst(ctparams, classParamsRange map (pt.paramRefs(_)))
117117
}
118118

119119
/** The bounds for the added type parameters of the polytype `pt` */
@@ -206,8 +206,7 @@ trait FullParameterization {
206206

207207
new TreeTypeMap(
208208
typeMap = rewireType(_)
209-
.substDealias(origTParams, trefs)
210-
.subst(origVParams, argRefs.map(_.tpe))
209+
.subst(origTParams ++ origVParams, trefs ++ argRefs.map(_.tpe))
211210
.substThisUnlessStatic(origClass, thisRef.tpe),
212211
treeMap = {
213212
case tree: This if tree.symbol == origClass => thisRef

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ class TailRec extends MiniPhase with FullParameterization {
134134
val origVParams = tree.vparamss.flatten map (_.symbol)
135135
new TreeTypeMap(
136136
typeMap = identity(_)
137-
.substDealias(origTParams, trefs)
138-
.subst(origVParams, vrefss.flatten.map(_.tpe)),
139-
oldOwners = origMeth :: Nil,
137+
.subst(origTParams ++ origVParams, trefs ++ vrefss.flatten.map(_.tpe)),
138+
oldOwners = origMeth :: Nil,
140139
newOwners = label :: Nil
141140
).transform(rhsSemiTransformed)
142141
})

0 commit comments

Comments
 (0)