@@ -1863,6 +1863,7 @@ object Parsers {
18631863 * Ascription ::= `:' InfixType
18641864 * | `:' Annotation {Annotation}
18651865 * | `:' `_' `*'
1866+ * Catches ::= ‘catch’ (Expr | ExprCaseClause)
18661867 */
18671868 val exprInParens : () => Tree = () => expr(Location .InParens )
18681869
@@ -1946,7 +1947,7 @@ object Parsers {
19461947 if in.token == CATCH then
19471948 val span = in.offset
19481949 in.nextToken()
1949- (if in.token == CASE then Match (EmptyTree , caseClause() :: Nil )
1950+ (if in.token == CASE then Match (EmptyTree , caseClause(exprOnly = true ) :: Nil )
19501951 else subExpr(),
19511952 span)
19521953 else (EmptyTree , - 1 )
@@ -2072,7 +2073,7 @@ object Parsers {
20722073 def matchClause (t : Tree ): Match =
20732074 in.endMarkerScope(MATCH ) {
20742075 atSpan(t.span.start, in.skipToken()) {
2075- Match (t, inBracesOrIndented(caseClauses(caseClause)))
2076+ Match (t, inBracesOrIndented(caseClauses(() => caseClause() )))
20762077 }
20772078 }
20782079
@@ -2366,7 +2367,7 @@ object Parsers {
23662367 def blockExpr (): Tree = atSpan(in.offset) {
23672368 val simplify = in.token == INDENT
23682369 inDefScopeBraces {
2369- if (in.token == CASE ) Match (EmptyTree , caseClauses(caseClause))
2370+ if (in.token == CASE ) Match (EmptyTree , caseClauses(() => caseClause() ))
23702371 else block(simplify)
23712372 }
23722373 }
@@ -2537,18 +2538,21 @@ object Parsers {
25372538 }
25382539
25392540 /** CaseClause ::= ‘case’ Pattern [Guard] `=>' Block
2541+ * ExprCaseClause ::= ‘case’ Pattern [Guard] ‘=>’ Expr
25402542 */
2541- val caseClause : () => CaseDef = () => atSpan(in.offset) {
2543+ def caseClause ( exprOnly : Boolean = false ) : CaseDef = atSpan(in.offset) {
25422544 val (pat, grd) = inSepRegion(LPAREN , RPAREN ) {
25432545 accept(CASE )
25442546 (pattern(), guard())
25452547 }
2546- CaseDef (pat, grd, atSpan(accept(ARROW )) { block() })
2548+ CaseDef (pat, grd, atSpan(accept(ARROW )) {
2549+ if exprOnly then expr() else block()
2550+ })
25472551 }
25482552
25492553 /** TypeCaseClause ::= ‘case’ InfixType ‘=>’ Type [nl]
25502554 */
2551- val typeCaseClause : () => CaseDef = () => atSpan(in.offset) {
2555+ def typeCaseClause () : CaseDef = atSpan(in.offset) {
25522556 val pat = inSepRegion(LPAREN , RPAREN ) {
25532557 accept(CASE )
25542558 infixType()
0 commit comments