Skip to content

Commit 3292231

Browse files
committed
Don't insert an <outdent> where a statement is logically continued
Thsi fixes a case observed in SJSCodeGen, which was basically like this: ```scala if (x) ... else /* bla bla } else */ { ``` The problem is that the commented out `}` in front of the uncommented `{` caused an <outdent> to be inserted.
1 parent 9bc37f2 commit 3292231

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,10 @@ object Scanners {
588588
if (nextWidth < lastWidth
589589
|| nextWidth == lastWidth && (indentPrefix == MATCH || indentPrefix == CATCH) && token != CASE)
590590
currentRegion match {
591-
case r: Indented if !r.isOutermost && !isLeadingInfixOperator() =>
591+
case r: Indented
592+
if !r.isOutermost &&
593+
!isLeadingInfixOperator() &&
594+
!statCtdTokens.contains(lastToken) =>
592595
currentRegion = r.enclosing
593596
insert(OUTDENT, offset)
594597
handleEndMarkers(nextWidth)

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ object messages {
578578
case class IllegalStartSimpleExpr(illegalToken: String)(implicit ctx: Context)
579579
extends Message(IllegalStartSimpleExprID) {
580580
val kind: String = "Syntax"
581-
val msg: String = "expression expected"
581+
val msg: String = em"expression expected but ${Red(illegalToken)} found"
582582
val explanation: String = {
583583
em"""|An expression cannot start with ${Red(illegalToken)}."""
584584
}

0 commit comments

Comments
 (0)