Skip to content

Commit 2a4d7bc

Browse files
committed
Fix case expansion for nullary functions.
Always expand to at least one parameter.
1 parent f0e54c5 commit 2a4d7bc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,12 +562,12 @@ object desugar {
562562
* ==>
563563
* x$1 => x$1 match { cases }
564564
*
565-
* If `nparams` != 1, expand instead to
565+
* If `nparams` > 1, expand instead to
566566
*
567-
* (x$0, ..., x${n-1}) => (x$0, ..., x${n-1}) match { cases }
567+
* (x$1, ..., x$n) => (x$0, ..., x${n-1}) match { cases }
568568
*/
569569
def makeCaseLambda(cases: List[CaseDef], nparams: Int = 1)(implicit ctx: Context) = {
570-
val params = (1 to nparams).toList.map(makeSyntheticParameter(_))
570+
val params = (1 to (nparams min 1)).toList.map(makeSyntheticParameter(_))
571571
val selector = makeTuple(params.map(p => Ident(p.name)))
572572
Function(params, Match(selector, cases))
573573
}

0 commit comments

Comments
 (0)