Skip to content

Commit 85c641f

Browse files
committed
Simplifications
- Use derivedLambdaType - Drop parameters of PolyTypes altogether
1 parent 7d1f78a commit 85c641f

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -647,27 +647,14 @@ object ProtoTypes {
647647
wildApprox(tp.resultType, theMap, seen, internal))
648648
case _: ThisType | _: BoundType => // default case, inlined for speed
649649
tp
650-
case tl: TypeLambda =>
650+
case tl: HKTypeLambda =>
651651
val internal1 = internal + tl
652-
val paramInfos = tl.paramInfos
653-
val paramInfos1 = tl.paramInfos.mapConserve {
654-
case tb @ TypeBounds(lo, hi) =>
655-
tb.derivedTypeBounds(
656-
wildApprox(lo, theMap, seen, internal1),
657-
wildApprox(hi, theMap, seen, internal1)
658-
)
659-
}
660-
val res = tl.resultType
661-
val res1 = wildApprox(res, theMap, seen, internal1)
662-
if ((res eq res1) && (paramInfos eq paramInfos1)) tl
663-
else {
664-
def substBounds(tl1: TypeLambda)(tb: TypeBounds): TypeBounds =
665-
tb.derivedTypeBounds(tb.lo.subst(tl, tl1), tb.hi.subst(tl, tl1))
666-
tl match {
667-
case _: HKTypeLambda => HKTypeLambda(tl.paramNames)(tl1 => paramInfos.map(substBounds(tl1)), tl1 => res1.subst(tl, tl1))
668-
case _: PolyType => PolyType(tl.paramNames)(tl1 => paramInfos.map(substBounds(tl1)), tl1 => res1.subst(tl, tl1))
669-
}
670-
}
652+
tl.derivedLambdaType(
653+
paramInfos = tl.paramInfos.mapConserve(wildApprox(_, theMap, seen, internal1).bounds),
654+
resType = wildApprox(tl.resType, theMap, seen, internal1)
655+
)
656+
case tl: PolyType =>
657+
wildApprox(tl.resType, theMap, seen, internal)
671658
case _ =>
672659
(if (theMap != null && seen.eq(theMap.seen)) theMap else new WildApproxMap(seen, internal))
673660
.mapOver(tp)

0 commit comments

Comments
 (0)