Skip to content

Commit 659ffeb

Browse files
committed
Avoid closure in newLikeThis
1 parent 8abe9da commit 659ffeb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3211,8 +3211,16 @@ object Types {
32113211
else newLikeThis(paramNames, paramInfos, resType)
32123212

32133213
def newLikeThis(paramNames: List[ThisName], paramInfos: List[PInfo], resType: Type)(using Context): This =
3214+
def substParams(pinfos: List[PInfo], to: This): List[PInfo] = pinfos match
3215+
case pinfo :: rest =>
3216+
val pinfo1 = pinfo.subst(this, to).asInstanceOf[PInfo]
3217+
val rest1 = substParams(rest, to)
3218+
if (pinfo1 eq pinfo) && (rest1 eq rest) then pinfos
3219+
else pinfo1 :: rest1
3220+
case nil =>
3221+
nil
32143222
companion(paramNames)(
3215-
x => paramInfos.mapConserve(_.subst(this, x).asInstanceOf[PInfo]),
3223+
x => substParams(paramInfos, x),
32163224
x => resType.subst(this, x))
32173225

32183226
protected def prefixString: String

0 commit comments

Comments
 (0)