diff options
author | Martin Odersky <odersky@gmail.com> | 2015-10-30 09:53:58 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-10-30 09:53:58 +0100 |
commit | f0e54c59520566b8d9d2b4dae8a4802de6b3a843 (patch) | |
tree | 92249fbd25a6cd76de690490bb114ac61b6c0fd1 /src/dotty/tools/dotc/typer/Typer.scala | |
parent | 201ce2f1d11bf3940291f6c800ec9dedead6c2a5 (diff) | |
download | dotty-f0e54c59520566b8d9d2b4dae8a4802de6b3a843.tar.gz dotty-f0e54c59520566b8d9d2b4dae8a4802de6b3a843.tar.bz2 dotty-f0e54c59520566b8d9d2b4dae8a4802de6b3a843.zip |
Allow pattern matching anonymous functions of arity > 1
This is sepcified in Sec. 8.5 of the SLS. Fixes #873. Review by @smarter.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 52ea32bbc..4c07e07de 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -629,7 +629,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def typedMatch(tree: untpd.Match, pt: Type)(implicit ctx: Context) = track("typedMatch") { tree.selector match { case EmptyTree => - typed(desugar.makeCaseLambda(tree.cases) withPos tree.pos, pt) + val arity = pt match { + case defn.FunctionType(args, _) => args.length + case _ => 1 + } + typed(desugar.makeCaseLambda(tree.cases, arity) withPos tree.pos, pt) case _ => val sel1 = typedExpr(tree.selector) val selType = widenForMatchSelector( |