Skip to content

Commit 9379c53

Browse files
committed
Revert "Fix #10056: Drop old context function closure syntax"
This reverts commit e75f7cc.
1 parent db39f61 commit 9379c53

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ object Parsers {
15021502
def typedFunParam(start: Offset, name: TermName, mods: Modifiers = EmptyModifiers): ValDef =
15031503
atSpan(start) {
15041504
accept(COLON)
1505-
makeParameter(name, typ(), mods)
1505+
makeParameter(name, typ(), mods | Param)
15061506
}
15071507

15081508
/** FunParamClause ::= ‘(’ TypedFunParam {‘,’ TypedFunParam } ‘)’
@@ -1864,14 +1864,14 @@ object Parsers {
18641864
accept(altToken)
18651865
t
18661866

1867-
/** Expr ::= [`implicit'] FunParams ‘=>’ Expr
1867+
/** Expr ::= [`implicit'] FunParams (‘=>’ | ‘?=>’) Expr
18681868
* | Expr1
18691869
* FunParams ::= Bindings
18701870
* | id
18711871
* | `_'
18721872
* ExprInParens ::= PostfixExpr `:' Type
18731873
* | Expr
1874-
* BlockResult ::= [‘implicit’] FunParams ‘=>’ Block
1874+
* BlockResult ::= [‘implicit’] FunParams (‘=>’ | ‘?=>’) Block
18751875
* | Expr1
18761876
* Expr1 ::= [‘inline’] `if' `(' Expr `)' {nl} Expr [[semi] else Expr]
18771877
* | [‘inline’] `if' Expr `then' Expr [[semi] else Expr]
@@ -2186,7 +2186,7 @@ object Parsers {
21862186

21872187
def closureRest(start: Int, location: Location, params: List[Tree]): Tree =
21882188
atSpan(start, in.offset) {
2189-
accept(ARROW)
2189+
if in.token == CTXARROW then in.nextToken() else accept(ARROW)
21902190
Function(params, if (location == Location.InBlock) block() else expr())
21912191
}
21922192

@@ -3773,7 +3773,7 @@ object Parsers {
37733773
case Typed(tree @ This(EmptyTypeIdent), tpt) =>
37743774
self = makeSelfDef(nme.WILDCARD, tpt).withSpan(first.span)
37753775
case _ =>
3776-
val ValDef(name, tpt, _) = convertToParam(first, "self type clause")
3776+
val ValDef(name, tpt, _) = convertToParam(first, EmptyModifiers, "self type clause")
37773777
if (name != nme.ERROR)
37783778
self = makeSelfDef(name, tpt).withSpan(first.span)
37793779
}

docs/docs/internals/syntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ Types ::= Type {‘,’ Type}
185185

186186
### Expressions
187187
```ebnf
188-
Expr ::= FunParams ‘=>’ Expr Function(args, expr), Function(ValDef([implicit], id, TypeTree(), EmptyTree), expr)
188+
Expr ::= FunParams (‘=>’ | ‘?=>’) Expr Function(args, expr), Function(ValDef([implicit], id, TypeTree(), EmptyTree), expr)
189189
| Expr1
190-
BlockResult ::= FunParams ‘=>’ Block
190+
BlockResult ::= FunParams (‘=>’ | ‘?=>’) Block
191191
| Expr1
192192
FunParams ::= Bindings
193193
| id

0 commit comments

Comments
 (0)