Skip to content

Commit 6be74d3

Browse files
Backport "Fix parsing of conditional expressions in parentheses" to LTS (#21006)
Backports #19985 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 29c9888 + bcbbf0a commit 6be74d3

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,8 @@ object Parsers {
20992099
def condExpr(altToken: Token): Tree =
21002100
val t: Tree =
21012101
if in.token == LPAREN then
2102-
var t: Tree = atSpan(in.offset) { Parens(inParens(exprInParens())) }
2102+
var t: Tree = atSpan(in.offset):
2103+
makeTupleOrParens(inParensWithCommas(commaSeparated(exprInParens)))
21032104
if in.token != altToken then
21042105
if toBeContinued(altToken) then
21052106
t = inSepRegion(InCond) {

tests/pos/if-parse.scala

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import scala.math.Ordering.Implicits.infixOrderingOps
2+
3+
def test =
4+
if (1, 2) < (3, 4) then 1 else 2

0 commit comments

Comments
 (0)