Skip to content

Commit df1c3c2

Browse files
committed
Better implementation of mapArgs
1 parent eeb1e86 commit df1c3c2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,7 +3452,7 @@ object Types {
34523452
if ((cls is PackageClass) || cls.owner.isTerm) symbolicTypeRef
34533453
else TypeRef(prefix, cls.name, clsDenot)
34543454
appliedRefCache =
3455-
tref.appliedTo(cls.typeParams.map(_.typeRef)) // @!!! cache?
3455+
tref.appliedTo(cls.typeParams.map(_.typeRef))
34563456
}
34573457
appliedRefCache
34583458
}
@@ -3562,7 +3562,6 @@ object Types {
35623562

35633563
class RealTypeBounds(lo: Type, hi: Type) extends TypeBounds(lo, hi)
35643564

3565-
// @!!! get rid of variance
35663565
abstract class TypeAlias(val alias: Type) extends TypeBounds(alias, alias) {
35673566

35683567
/** pre: this is a type alias */
@@ -3829,12 +3828,17 @@ object Types {
38293828
| NoPrefix => tp
38303829

38313830
case tp: AppliedType =>
3832-
def mapArg(arg: Type, tparam: ParamInfo): Type = arg match {
3833-
case arg: TypeBounds => this(arg)
3834-
case _ => atVariance(variance * tparam.paramVariance)(this(arg))
3831+
def mapArgs(args: List[Type], tparams: List[ParamInfo]): List[Type] = args match {
3832+
case arg :: args1 =>
3833+
val arg1 = arg match {
3834+
case arg: TypeBounds => this(arg)
3835+
case arg => atVariance(variance * tparams.head.paramVariance)(this(arg))
3836+
}
3837+
arg1 :: mapArgs(args1, tparams.tail)
3838+
case nil =>
3839+
nil
38353840
}
3836-
derivedAppliedType(tp, this(tp.tycon),
3837-
tp.args.zipWithConserve(tp.typeParams)(mapArg))
3841+
derivedAppliedType(tp, this(tp.tycon), mapArgs(tp.args, tp.typeParams))
38383842

38393843
case tp: RefinedType =>
38403844
derivedRefinedType(tp, this(tp.parent), this(tp.refinedInfo))

0 commit comments

Comments
 (0)