@@ -2383,6 +2383,7 @@ object Parsers {
23832383
23842384 /** Expr ::= [`implicit'] FunParams (‘=>’ | ‘?=>’) Expr
23852385 * | TypTypeParamClause ‘=>’ Expr
2386+ * | ExprCaseClause
23862387 * | Expr1
23872388 * FunParams ::= Bindings
23882389 * | id
@@ -2434,6 +2435,8 @@ object Parsers {
24342435 val arrowOffset = accept(ARROW )
24352436 val body = expr(location)
24362437 makePolyFunction(tparams, body, " literal" , errorTermTree(arrowOffset), start, arrowOffset)
2438+ case CASE =>
2439+ singleCaseMatch()
24372440 case _ =>
24382441 val saved = placeholderParams
24392442 placeholderParams = Nil
@@ -2497,9 +2500,8 @@ object Parsers {
24972500 if in.token == CATCH then
24982501 val span = in.offset
24992502 in.nextToken()
2500- (if in.token == CASE then Match (EmptyTree , caseClause(exprOnly = true ) :: Nil )
2501- else subExpr(),
2502- span)
2503+ (if in.token == CASE then singleCaseMatch() else subExpr(),
2504+ span)
25032505 else (EmptyTree , - 1 )
25042506
25052507 handler match {
@@ -3193,9 +3195,9 @@ object Parsers {
31933195 case ARROW => atSpan(in.skipToken()):
31943196 if exprOnly then
31953197 if in.indentSyntax && in.isAfterLineEnd && in.token != INDENT then
3196- warning(em """ Misleading indentation: this expression forms part of the preceding catch case.
3198+ warning(em """ Misleading indentation: this expression forms part of the preceding case.
31973199 |If this is intended, it should be indented for clarity.
3198- |Otherwise, if the handler is intended to be empty, use a multi-line catch with
3200+ |Otherwise, if the handler is intended to be empty, use a multi-line match or catch with
31993201 |an indented case. """ )
32003202 expr()
32013203 else block()
@@ -3212,6 +3214,9 @@ object Parsers {
32123214 CaseDef (pat, grd1, body)
32133215 }
32143216
3217+ def singleCaseMatch () =
3218+ Match (EmptyTree , caseClause(exprOnly = true ) :: Nil )
3219+
32153220 /** TypeCaseClause ::= ‘case’ (InfixType | ‘_’) ‘=>’ Type [semi]
32163221 */
32173222 def typeCaseClause (): CaseDef = atSpan(in.offset) {
0 commit comments