Skip to content

Commit d7fb8bf

Browse files
committed
Fix fixes in backend and improve warning message
In fact the warning occurrences in the backend were also assuming an empty catch handler. Change them to do the right thing, and fix the warning message to point out this possibility.
1 parent 36300dc commit d7fb8bf

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

compiler/src/dotty/tools/backend/jvm/BytecodeWriters.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ trait BytecodeWriters {
117117
catch case ex: ClosedByInterruptException =>
118118
try
119119
outfile.delete() // don't leave an empty or half-written classfile around after an interrupt
120-
catch case _: Throwable =>
121-
throw ex
120+
catch
121+
case _: Throwable =>
122+
throw ex
122123
finally outstream.close()
123124
report.informProgress("wrote '" + label + "' to " + outfile)
124125
}

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,9 @@ class GenBCodePipeline(val int: DottyBackendInterface, val primitives: DottyPrim
275275
catch case ex: ClosedByInterruptException =>
276276
try
277277
outTastyFile.delete() // don't leave an empty or half-written tastyfile around after an interrupt
278-
catch case _: Throwable =>
279-
throw ex
278+
catch
279+
case _: Throwable =>
280+
throw ex
280281
finally outstream.close()
281282

282283
val uuid = new TastyHeaderUnpickler(binary()).readHeader()

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,8 +2622,10 @@ object Parsers {
26222622
CaseDef(pat, grd, atSpan(accept(ARROW)) {
26232623
if exprOnly then
26242624
if in.indentSyntax && in.isAfterLineEnd && in.token != INDENT then
2625-
warning(i"""misleading indentation: this expression forms part of the preceding catch case,
2626-
|it should be indented for clarity.""")
2625+
warning(i"""Misleading indentation: this expression forms part of the preceding catch case.
2626+
|If this is intended, it should be indented for clarity.
2627+
|Otherwise, if the handler is intended to be empty, use a multi-line catch with
2628+
|an indented case.""")
26272629
expr()
26282630
else block()
26292631
})

0 commit comments

Comments
 (0)