@@ -700,7 +700,7 @@ class Namer { typer: Typer =>
700
700
case original : DefDef =>
701
701
val typer1 = ctx.typer.newLikeThis
702
702
nestedTyper(sym) = typer1
703
- typer1.defDefSig(original, sym)(using localContext(sym).setTyper(typer1))
703
+ typer1.defDefSig(original, sym, this )(using localContext(sym).setTyper(typer1))
704
704
case imp : Import =>
705
705
try
706
706
val expr1 = typedImportQualifier(imp, typedAheadExpr(_, _)(using ctx.withOwner(sym)))
@@ -733,6 +733,15 @@ class Namer { typer: Typer =>
733
733
completer.complete(denot)
734
734
}
735
735
736
+ private var completedTypeParamSyms : List [TypeSymbol ] = null
737
+
738
+ def setCompletedTypeParams (tparams : List [TypeSymbol ]) =
739
+ completedTypeParamSyms = tparams
740
+
741
+ override def completerTypeParams (sym : Symbol )(using Context ): List [TypeSymbol ] =
742
+ if completedTypeParamSyms != null then completedTypeParamSyms
743
+ else Nil
744
+
736
745
protected def addAnnotations (sym : Symbol ): Unit = original match {
737
746
case original : untpd.MemberDef =>
738
747
lazy val annotCtx = annotContext(original, sym)
@@ -1639,7 +1648,7 @@ class Namer { typer: Typer =>
1639
1648
}
1640
1649
1641
1650
/** The type signature of a DefDef with given symbol */
1642
- def defDefSig (ddef : DefDef , sym : Symbol )(using Context ): Type = {
1651
+ def defDefSig (ddef : DefDef , sym : Symbol , completer : Namer # Completer )(using Context ): Type = {
1643
1652
// Beware: ddef.name need not match sym.name if sym was freshened!
1644
1653
val isConstructor = sym.name == nme.CONSTRUCTOR
1645
1654
@@ -1668,8 +1677,10 @@ class Namer { typer: Typer =>
1668
1677
// 5. Info of CP is copied to DP and DP is completed.
1669
1678
index(ddef.leadingTypeParams)
1670
1679
if (isConstructor) sym.owner.typeParams.foreach(_.ensureCompleted())
1671
- for (tparam <- ddef.leadingTypeParams) typedAheadExpr(tparam)
1672
-
1680
+ val completedTypeParams =
1681
+ for tparam <- ddef.leadingTypeParams yield typedAheadExpr(tparam).symbol
1682
+ if completedTypeParams.forall(_.isType) then
1683
+ completer.setCompletedTypeParams(completedTypeParams.asInstanceOf [List [TypeSymbol ]])
1673
1684
ddef.trailingParamss.foreach(completeParams)
1674
1685
val paramSymss = normalizeIfConstructor(ddef.paramss.nestedMap(symbolOfTree), isConstructor)
1675
1686
sym.setParamss(paramSymss)
0 commit comments