@@ -1316,33 +1316,39 @@ object desugar {
13161316 Function (params, Match (makeSelector(selector, checkMode), cases))
13171317 }
13181318
1319- /** Map n-ary function `(p1 , ..., pn ) => body` where n != 1 to unary function as follows:
1319+ /** Map n-ary function `(x1: T1 , ..., xn: Tn ) => body` where n != 1 to unary function as follows:
13201320 *
1321- * x$1 => {
1322- * def p1 = x$1._1
1321+ * ( x$1: (T1, ..., Tn)) => {
1322+ * def x1: T1 = x$1._1
13231323 * ...
1324- * def pn = x$1._n
1324+ * def xn: Tn = x$1._n
13251325 * body
13261326 * }
13271327 *
13281328 * or if `isGenericTuple`
13291329 *
1330- * x$1 => {
1331- * def p1 = x$1.apply(0)
1330+ * ( x$1: (T1, ... Tn) => {
1331+ * def x1: T1 = x$1.apply(0)
13321332 * ...
1333- * def pn = x$1.apply(n-1)
1333+ * def xn: Tn = x$1.apply(n-1)
13341334 * body
13351335 * }
1336+ *
1337+ * If some of the Ti's are absent, omit the : (T1, ..., Tn) type ascription
1338+ * in the selector.
13361339 */
13371340 def makeTupledFunction (params : List [ValDef ], body : Tree , isGenericTuple : Boolean )(implicit ctx : Context ): Tree = {
1338- val param = makeSyntheticParameter()
1341+ val param = makeSyntheticParameter(
1342+ tpt =
1343+ if params.exists(_.tpt.isEmpty) then TypeTree ()
1344+ else Tuple (params.map(_.tpt)))
13391345 def selector (n : Int ) =
13401346 if (isGenericTuple) Apply (Select (refOfDef(param), nme.apply), Literal (Constant (n)))
13411347 else Select (refOfDef(param), nme.selectorName(n))
13421348 val vdefs =
13431349 params.zipWithIndex.map {
13441350 case (param, idx) =>
1345- DefDef (param.name, Nil , Nil , TypeTree () , selector(idx)).withSpan(param.span)
1351+ DefDef (param.name, Nil , Nil , param.tpt , selector(idx)).withSpan(param.span)
13461352 }
13471353 Function (param :: Nil , Block (vdefs, body))
13481354 }
0 commit comments