Skip to content

Commit 46bef71

Browse files
authored
Merge pull request #1822 from dotty-staging/fix-#1792
Fix #1792: Allow newline in front of `{` for procedure syntax
2 parents 7866bc2 + 2423ada commit 46bef71

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,6 +1947,7 @@ object Parsers {
19471947
if (in.token == THIS) {
19481948
in.nextToken()
19491949
val vparamss = paramClauses(nme.CONSTRUCTOR)
1950+
if (in.isScala2Mode) newLineOptWhenFollowedBy(LBRACE)
19501951
val rhs = {
19511952
if (!(in.token == LBRACE && scala2ProcedureSyntax(""))) accept(EQUALS)
19521953
atPos(in.offset) { constrExpr() }
@@ -1958,6 +1959,7 @@ object Parsers {
19581959
val tparams = typeParamClauseOpt(ParamOwner.Def)
19591960
val vparamss = paramClauses(name)
19601961
var tpt = fromWithinReturnType(typedOpt())
1962+
if (in.isScala2Mode) newLineOptWhenFollowedBy(LBRACE)
19611963
val rhs =
19621964
if (in.token == EQUALS) {
19631965
in.nextToken()

tests/pos-scala2/i1792.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object Test {
2+
3+
def foo(x: Int)
4+
{
5+
x
6+
}
7+
8+
}

0 commit comments

Comments
 (0)