Skip to content

Commit 42eb08a

Browse files
committed
Make sure that fewerBraces as default will not work for 3.0-migration
Under 3.0-migration { x: T => expr } Is legal code but it's forbidden for later versions. If `fewerBraces` was the default, that code would be ambiguous.
1 parent 69c4ad5 commit 42eb08a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,12 @@ object Scanners {
214214
if fewerBracesEnabledCtx ne myLanguageImportContext then
215215
fewerBracesEnabledCache =
216216
featureEnabled(Feature.fewerBraces)
217-
|| fewerBracesByDefault && indentSyntax
217+
|| fewerBracesByDefault && indentSyntax && !migrateTo3
218+
// ensure that fewer braces is not the default for 3.0-migration since
219+
// { x: T =>
220+
// expr
221+
// }
222+
// would be ambiguous
218223
fewerBracesEnabledCtx = myLanguageImportContext
219224
fewerBracesEnabledCache
220225

tests/rewrites/rewrites.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object test3 {
5656
}
5757
}
5858
}
59-
def g = { (x: Int) =>
59+
def g = { x: Int =>
6060
x + 1
6161
}
6262
}

0 commit comments

Comments
 (0)