diff --git a/compiler/src/dotty/tools/dotc/core/Substituters.scala b/compiler/src/dotty/tools/dotc/core/Substituters.scala index 9faff4b661f6..465e0d251203 100644 --- a/compiler/src/dotty/tools/dotc/core/Substituters.scala +++ b/compiler/src/dotty/tools/dotc/core/Substituters.scala @@ -73,35 +73,6 @@ trait Substituters { this: Context => } } - final def substDealias(tp: Type, from: List[Symbol], to: List[Type], theMap: SubstDealiasMap): Type = { - tp match { - case tp: NamedType => - val sym = tp.symbol - var fs = from - var ts = to - while (fs.nonEmpty) { - if (fs.head eq sym) return ts.head - fs = fs.tail - ts = ts.tail - } - if (sym.isStatic && !existsStatic(from) || (tp.prefix `eq` NoPrefix)) tp - else { - tp.info match { - case TypeAlias(alias) => - val alias1 = substDealias(alias, from, to, theMap) - if (alias1 ne alias) return alias1 - case _ => - } - tp.derivedSelect(substDealias(tp.prefix, from, to, theMap)) - } - case _: ThisType | _: BoundType => - tp - case _ => - (if (theMap != null) theMap else new SubstDealiasMap(from, to)) - .mapOver(tp) - } - } - final def substSym(tp: Type, from: List[Symbol], to: List[Symbol], theMap: SubstSymMap): Type = tp match { case tp: NamedType => @@ -210,10 +181,6 @@ trait Substituters { this: Context => def apply(tp: Type): Type = subst(tp, from, to, this) } - final class SubstDealiasMap(from: List[Symbol], to: List[Type]) extends DeepTypeMap { - override def apply(tp: Type): Type = substDealias(tp, from, to, this) - } - final class SubstSymMap(from: List[Symbol], to: List[Symbol]) extends DeepTypeMap { def apply(tp: Type): Type = substSym(tp, from, to, this) } diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index c30f711c6096..2976d08bc883 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -1307,17 +1307,6 @@ object Types { } } - /** Same as `subst` but follows aliases as a fallback. When faced with a reference - * to an alias type, where normal substitution does not yield a new type, the - * substitution is instead applied to the alias. If that yields a new type, - * this type is returned, otherwise the original type (not the alias) is returned. - * A use case for this method is if one wants to substitute the type parameters - * of a class and also wants to substitute any parameter accessors that alias - * the type parameters. - */ - final def substDealias(from: List[Symbol], to: List[Type])(implicit ctx: Context): Type = - ctx.substDealias(this, from, to, null) - /** Substitute all types of the form `TypeParamRef(from, N)` by * `TypeParamRef(to, N)`. */ diff --git a/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala b/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala index a950bf7c4f49..dc5ffa8df3a9 100644 --- a/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala +++ b/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala @@ -113,7 +113,7 @@ trait FullParameterization { /** Replace class type parameters by the added type parameters of the polytype `pt` */ def mapClassParams(tp: Type, pt: PolyType): Type = { val classParamsRange = (mtparamCount until mtparamCount + ctparams.length).toList - tp.substDealias(ctparams, classParamsRange map (pt.paramRefs(_))) + tp.subst(ctparams, classParamsRange map (pt.paramRefs(_))) } /** The bounds for the added type parameters of the polytype `pt` */ @@ -206,8 +206,7 @@ trait FullParameterization { new TreeTypeMap( typeMap = rewireType(_) - .substDealias(origTParams, trefs) - .subst(origVParams, argRefs.map(_.tpe)) + .subst(origTParams ++ origVParams, trefs ++ argRefs.map(_.tpe)) .substThisUnlessStatic(origClass, thisRef.tpe), treeMap = { case tree: This if tree.symbol == origClass => thisRef diff --git a/compiler/src/dotty/tools/dotc/transform/TailRec.scala b/compiler/src/dotty/tools/dotc/transform/TailRec.scala index 6ef41144204b..5700f63b57d0 100644 --- a/compiler/src/dotty/tools/dotc/transform/TailRec.scala +++ b/compiler/src/dotty/tools/dotc/transform/TailRec.scala @@ -136,9 +136,8 @@ class TailRec extends MiniPhase with FullParameterization { val origVParams = tree.vparamss.flatten map (_.symbol) new TreeTypeMap( typeMap = identity(_) - .substDealias(origTParams, trefs) - .subst(origVParams, vrefss.flatten.map(_.tpe)), - oldOwners = origMeth :: Nil, + .subst(origTParams ++ origVParams, trefs ++ vrefss.flatten.map(_.tpe)), + oldOwners = origMeth :: Nil, newOwners = label :: Nil ).transform(rhsSemiTransformed) })