Skip to content

Commit c31204f

Browse files
committed
Allow newlines before parameter lists
Allow newline characters before a `(` token that starts a formal parameter list.
1 parent e59cd6c commit c31204f

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

compiler/src/dotty/tools/dotc/core/Flags.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package dotty.tools.dotc
22
package core
33

4-
import language.implicitConversions
5-
64
object Flags {
75

86
object opaques {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,6 +2305,7 @@ object Parsers {
23052305
ofInstance: Boolean = false): List[List[ValDef]] = {
23062306
def recur(firstClause: Boolean, nparams: Int, contextualOnly: Boolean): List[List[ValDef]] = {
23072307
var initialMods = EmptyModifiers
2308+
newLineOptWhenFollowedBy(LPAREN)
23082309
if (in.token == GIVEN) {
23092310
in.nextToken()
23102311
initialMods |= Given

docs/docs/internals/syntax.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ HkTypeParam ::= {Annotation} [‘+’ | ‘-’] (Id[HkTypeParamClause] |
298298
299299
ClsParamClauses ::= {ClsParamClause} [[nl] ‘(’ [‘implicit’] ClsParams ‘)’]
300300
| {ClsParamClause} {GivenClsParamClause}
301-
ClsParamClause ::= ‘(’ ClsParams ‘)’
301+
ClsParamClause ::= [nl] ‘(’ ClsParams ‘)’
302302
GivenClsParamClause::= ‘given’ (‘(’ ClsParams ‘)’ | GivenTypes)
303303
ClsParams ::= ClsParam {‘,’ ClsParam}
304304
ClsParam ::= {Annotation} ValDef(mods, id, tpe, expr) -- point of mods on val/var
@@ -308,7 +308,7 @@ Param ::= id ‘:’ ParamType [‘=’ Expr]
308308
309309
DefParamClauses ::= {DefParamClause} [[nl] ‘(’ [‘implicit’] DefParams ‘)’]
310310
| {DefParamClause} {GivenParamClause}
311-
DefParamClause ::= ‘(’ DefParams ‘)’
311+
DefParamClause ::= [nl] ‘(’ DefParams ‘)’
312312
GivenParamClause ::= ‘given’ (‘(’ DefParams ‘)’ | GivenTypes)
313313
DefParams ::= DefParam {‘,’ DefParam}
314314
DefParam ::= {Annotation} [‘inline’] Param ValDef(mods, id, tpe, expr) -- point of mods at id.
@@ -356,7 +356,7 @@ Dcl ::= RefineDcl
356356
| ‘var’ VarDcl
357357
ValDcl ::= ids ‘:’ Type PatDef(_, ids, tpe, EmptyTree)
358358
VarDcl ::= ids ‘:’ Type PatDef(_, ids, tpe, EmptyTree)
359-
DefDcl ::= DefSig [‘:’ Type] DefDef(_, name, tparams, vparamss, tpe, EmptyTree)
359+
DefDcl ::= DefSig ‘:’ Type DefDef(_, name, tparams, vparamss, tpe, EmptyTree)
360360
DefSig ::= [‘(’ DefParam ‘)’ [nl]] id
361361
[DefTypeParamClause] DefParamClauses
362362
TypeDcl ::= id [TypeParamClause] SubtypeBounds [‘=’ Type] TypeDefTree(_, name, tparams, bound

tests/pos/i5978.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ package p1 {
99
object TextParser {
1010
delegate TP for TokenParser[Char, Position[CharSequence]] {}
1111

12+
def f given
13+
TokenParser[Char, Position[CharSequence]] = ???
14+
1215
delegate FromCharToken for Conversion[Char, Position[CharSequence]]
1316
given (T: TokenParser[Char, Position[CharSequence]])= ???
1417
}

0 commit comments

Comments
 (0)