Skip to content

Commit e6f5df6

Browse files
committed
Refactor: Move allParamSyms to TreeInfo
1 parent e5bdd2e commit e6f5df6

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,9 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
191191
case arg => arg.typeOpt.widen.isRepeatedParam
192192
}
193193

194-
/** If this tree has type parameters, those. Otherwise Nil.
195-
def typeParameters(tree: Tree): List[TypeDef] = tree match {
196-
case DefDef(_, _, tparams, _, _, _) => tparams
197-
case ClassDef(_, _, tparams, _) => tparams
198-
case TypeDef(_, _, tparams, _) => tparams
199-
case _ => Nil
200-
}*/
194+
/** All type and value parameter symbols of this DefDef */
195+
def allParamSyms(ddef: DefDef)(using Context): List[Symbol] =
196+
(ddef.tparams ::: ddef.vparamss.flatten).map(_.symbol)
201197

202198
/** Does this argument list end with an argument of the form <expr> : _* ? */
203199
def isWildcardStarArgList(trees: List[Tree])(implicit ctx: Context): Boolean =

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -924,10 +924,8 @@ object Erasure {
924924
stats.mapConserve {
925925
case stat: DefDef if stat.symbol.isInlineMethod && stat.symbol.isInlineRetained =>
926926
val rdef = retainerDef(stat.symbol)
927-
def allParams(ddef: DefDef) =
928-
(ddef.tparams ::: ddef.vparamss.flatten).map(_.symbol)
929-
val fromParams = allParams(rdef)
930-
val toParams = allParams(stat)
927+
val fromParams = untpd.allParamSyms(rdef)
928+
val toParams = untpd.allParamSyms(stat)
931929
assert(fromParams.hasSameLengthAs(toParams))
932930
val mapBody = TreeTypeMap(
933931
oldOwners = rdef.symbol :: Nil,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class HoistSuperArgs extends MiniPhase with IdentityDenotTransformer { thisPhase
6969
if (constr == cls.primaryConstructor)
7070
cls.info.decls.filter(d => d.is(TypeParam) || d.is(ParamAccessor))
7171
else
72-
(cdef.tparams ::: cdef.vparamss.flatten).map(_.symbol)
72+
allParamSyms(cdef)
7373

7474
/** The parameter references defined by the constructor info */
7575
def allParamRefs(tp: Type): List[ParamRef] = tp match {

0 commit comments

Comments
 (0)