Skip to content

Commit d67ceec

Browse files
committed
When assigning type cases, substitute any instances of type parameters for the applied arguments
1 parent 5a4a571 commit d67ceec

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,19 @@ trait TypeAssigner {
401401
def assignType(tree: untpd.CaseDef, pat: Tree, body: Tree)(using Context): CaseDef = {
402402
val ownType =
403403
if (body.isType) {
404-
val params = new TreeAccumulator[mutable.ListBuffer[TypeSymbol]] {
404+
val getParams = new TreeAccumulator[mutable.ListBuffer[TypeSymbol]] {
405405
def apply(ps: mutable.ListBuffer[TypeSymbol], t: Tree)(using Context) = t match {
406406
case t: Bind if t.symbol.isType => foldOver(ps += t.symbol.asType, t)
407407
case _ => foldOver(ps, t)
408408
}
409409
}
410-
HKTypeLambda.fromParams(
411-
params(new mutable.ListBuffer[TypeSymbol](), pat).toList,
412-
defn.MatchCase(pat.tpe, body.tpe))
410+
val params = getParams(new mutable.ListBuffer[TypeSymbol](), pat).toList
411+
pat.tpe match
412+
case AppliedType(tycon, args) =>
413+
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))
413417
}
414418
else body.tpe
415419
tree.withType(ownType)

tests/neg/6697.check

Lines changed: 0 additions & 13 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)