Skip to content

Commit 2423ada

Browse files
committed
Fix #1792: Allow newline in front of { when supporting procedure syntax.
1 parent ba06bf0 commit 2423ada

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
@@ -1897,6 +1897,7 @@ object Parsers {
18971897
if (in.token == THIS) {
18981898
in.nextToken()
18991899
val vparamss = paramClauses(nme.CONSTRUCTOR)
1900+
if (in.isScala2Mode) newLineOptWhenFollowedBy(LBRACE)
19001901
val rhs = {
19011902
if (!(in.token == LBRACE && scala2ProcedureSyntax(""))) accept(EQUALS)
19021903
atPos(in.offset) { constrExpr() }
@@ -1908,6 +1909,7 @@ object Parsers {
19081909
val tparams = typeParamClauseOpt(ParamOwner.Def)
19091910
val vparamss = paramClauses(name)
19101911
var tpt = fromWithinReturnType(typedOpt())
1912+
if (in.isScala2Mode) newLineOptWhenFollowedBy(LBRACE)
19111913
val rhs =
19121914
if (in.token == EQUALS) {
19131915
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)