Skip to content

Commit 81cc6f1

Browse files
committed
Use substSym instead of mutating symbols
1 parent 3a00dc5 commit 81cc6f1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,19 @@ trait TypeAssigner {
407407
case _ => foldOver(ps, t)
408408
}
409409
}
410-
val params = getParams(new mutable.ListBuffer[TypeSymbol](), pat).toList
411-
pat.tpe match
410+
val params1 = getParams(new mutable.ListBuffer[TypeSymbol](), pat).toList
411+
val params2 = pat.tpe match
412412
case AppliedType(tycon, args) =>
413413
val tparams = tycon.typeParamSymbols
414-
for param <- params do param.info = param.info.subst(tparams, args)
415-
case _ =>
416-
HKTypeLambda.fromParams(params, defn.MatchCase(pat.tpe, body.tpe))
414+
params1.mapconserve { param =>
415+
val info1 = param.info
416+
val info2 = info1.subst(tparams, args)
417+
if info2 eq info1 then param else param.copy(info = info2).asType
418+
}
419+
case _ => params1
420+
val matchCase1 = defn.MatchCase(pat.tpe, body.tpe)
421+
val matchCase2 = if params2 eq params1 then matchCase1 else matchCase1.substSym(params1, params2)
422+
HKTypeLambda.fromParams(params2, matchCase2)
417423
}
418424
else body.tpe
419425
tree.withType(ownType)

0 commit comments

Comments
 (0)