@@ -700,7 +700,7 @@ class Namer { typer: Typer =>
700700 case original : DefDef =>
701701 val typer1 = ctx.typer.newLikeThis
702702 nestedTyper(sym) = typer1
703- typer1.defDefSig(original, sym)(using localContext(sym).setTyper(typer1))
703+ typer1.defDefSig(original, sym, this )(using localContext(sym).setTyper(typer1))
704704 case imp : Import =>
705705 try
706706 val expr1 = typedImportQualifier(imp, typedAheadExpr(_, _)(using ctx.withOwner(sym)))
@@ -733,6 +733,15 @@ class Namer { typer: Typer =>
733733 completer.complete(denot)
734734 }
735735
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+
736745 protected def addAnnotations (sym : Symbol ): Unit = original match {
737746 case original : untpd.MemberDef =>
738747 lazy val annotCtx = annotContext(original, sym)
@@ -1639,7 +1648,7 @@ class Namer { typer: Typer =>
16391648 }
16401649
16411650 /** 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 = {
16431652 // Beware: ddef.name need not match sym.name if sym was freshened!
16441653 val isConstructor = sym.name == nme.CONSTRUCTOR
16451654
@@ -1668,8 +1677,10 @@ class Namer { typer: Typer =>
16681677 // 5. Info of CP is copied to DP and DP is completed.
16691678 index(ddef.leadingTypeParams)
16701679 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 ]])
16731684 ddef.trailingParamss.foreach(completeParams)
16741685 val paramSymss = normalizeIfConstructor(ddef.paramss.nestedMap(symbolOfTree), isConstructor)
16751686 sym.setParamss(paramSymss)
0 commit comments