Skip to content

Commit f8bf15b

Browse files
committed
Fix crash when trying to insert braces at EOF
This fixes a crash when trying to compile pos/indent2.scala with -rewrite -noindent. Ideally we should have a test for this. However, I am not sure whether our current test infrastructure supports rewrite tests.
1 parent a08079e commit f8bf15b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ object Parsers {
633633
* at indent width greater than the indent width of the closing brace.
634634
*/
635635
def closingOffset(lineStart: Offset): Offset =
636-
if (lineStart >= in.lineOffset) in.lineOffset
636+
if (in.lineOffset >= 0 && lineStart >= in.lineOffset) in.lineOffset
637637
else {
638638
val candidate = source.nextLine(lineStart)
639639
val commentStart = skipBlanks(lineStart)

0 commit comments

Comments
 (0)