@@ -988,6 +988,20 @@ class Namer { typer: Typer =>
988988 * provided `mbr` is accessible and of the right implicit/non-implicit kind.
989989 */
990990 def addForwarder (alias : TermName , mbr : SingleDenotation , span : Span ): Unit =
991+ def adaptForwarderParams (acc : List [List [tpd.Tree ]], tp : Type , prefss : List [List [tpd.Tree ]])
992+ : List [List [tpd.Tree ]] = tp match
993+ case mt : MethodType =>
994+ // Note: in this branch we use the assumptions
995+ // that `prefss.head` corresponds to `mt.paramInfos` and
996+ // that `prefss.tail` corresponds to `mt.resType`
997+ if mt.paramInfos.nonEmpty && mt.paramInfos.last.isRepeatedParam then
998+ val init :+ vararg = prefss.head
999+ val prefs = init :+ ctx.typeAssigner.seqToRepeated(vararg)
1000+ adaptForwarderParams(prefs :: acc, mt.resType, prefss.tail)
1001+ else
1002+ adaptForwarderParams(prefss.head :: acc, mt.resType, prefss.tail)
1003+ case _ =>
1004+ acc.reverse ::: prefss
9911005 if (whyNoForwarder(mbr) == " " ) {
9921006 val sym = mbr.symbol
9931007 val forwarder =
@@ -1024,7 +1038,8 @@ class Namer { typer: Typer =>
10241038 import tpd ._
10251039 val ref = path.select(sym.asTerm)
10261040 val ddef = tpd.polyDefDef(forwarder.asTerm, targs => prefss =>
1027- ref.appliedToTypes(targs).appliedToArgss(prefss)
1041+ ref.appliedToTypes(targs)
1042+ .appliedToArgss(adaptForwarderParams(Nil , sym.info.stripPoly, prefss))
10281043 )
10291044 if forwarder.isInlineMethod then
10301045 PrepareInlineable .registerInlineInfo(forwarder, ddef.rhs)
0 commit comments