Skip to content

Commit

Permalink
Backport "Fix parsing of conditional expressions in parentheses" to L…
Browse files Browse the repository at this point in the history
…TS (#21006)

Backports #19985 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jul 4, 2024
2 parents 29c9888 + bcbbf0a commit 6be74d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,8 @@ object Parsers {
def condExpr(altToken: Token): Tree =
val t: Tree =
if in.token == LPAREN then
var t: Tree = atSpan(in.offset) { Parens(inParens(exprInParens())) }
var t: Tree = atSpan(in.offset):
makeTupleOrParens(inParensWithCommas(commaSeparated(exprInParens)))
if in.token != altToken then
if toBeContinued(altToken) then
t = inSepRegion(InCond) {
Expand Down
4 changes: 4 additions & 0 deletions tests/pos/if-parse.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import scala.math.Ordering.Implicits.infixOrderingOps

def test =
if (1, 2) < (3, 4) then 1 else 2

0 comments on commit 6be74d3

Please sign in to comment.