@@ -2378,6 +2378,7 @@ object Parsers {
23782378
23792379 /** Expr ::= [`implicit'] FunParams (‘=>’ | ‘?=>’) Expr
23802380 * | TypTypeParamClause ‘=>’ Expr
2381+ * | ExprCaseClause
23812382 * | Expr1
23822383 * FunParams ::= Bindings
23832384 * | id
@@ -2429,6 +2430,8 @@ object Parsers {
24292430 val arrowOffset = accept(ARROW )
24302431 val body = expr(location)
24312432 makePolyFunction(tparams, body, " literal" , errorTermTree(arrowOffset), start, arrowOffset)
2433+ case CASE =>
2434+ singleCaseMatch()
24322435 case _ =>
24332436 val saved = placeholderParams
24342437 placeholderParams = Nil
@@ -2492,9 +2495,8 @@ object Parsers {
24922495 if in.token == CATCH then
24932496 val span = in.offset
24942497 in.nextToken()
2495- (if in.token == CASE then Match (EmptyTree , caseClause(exprOnly = true ) :: Nil )
2496- else subExpr(),
2497- span)
2498+ (if in.token == CASE then singleCaseMatch() else subExpr(),
2499+ span)
24982500 else (EmptyTree , - 1 )
24992501
25002502 handler match {
@@ -3188,9 +3190,9 @@ object Parsers {
31883190 case ARROW => atSpan(in.skipToken()):
31893191 if exprOnly then
31903192 if in.indentSyntax && in.isAfterLineEnd && in.token != INDENT then
3191- warning(em """ Misleading indentation: this expression forms part of the preceding catch case.
3193+ warning(em """ Misleading indentation: this expression forms part of the preceding case.
31923194 |If this is intended, it should be indented for clarity.
3193- |Otherwise, if the handler is intended to be empty, use a multi-line catch with
3195+ |Otherwise, if the handler is intended to be empty, use a multi-line match or catch with
31943196 |an indented case. """ )
31953197 expr()
31963198 else block()
@@ -3206,6 +3208,9 @@ object Parsers {
32063208 CaseDef (pat, grd1, body)
32073209 }
32083210
3211+ def singleCaseMatch () =
3212+ Match (EmptyTree , caseClause(exprOnly = true ) :: Nil )
3213+
32093214 /** TypeCaseClause ::= ‘case’ (InfixType | ‘_’) ‘=>’ Type [semi]
32103215 */
32113216 def typeCaseClause (): CaseDef = atSpan(in.offset) {
0 commit comments