Skip to content

Commit 69a280f

Browse files
committed
Fix output of decompiler when emitting to a file
1 parent 7655503 commit 69a280f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DecompilationPrinter extends Phase {
2424
var os: OutputStream = null
2525
var ps: PrintStream = null
2626
try {
27-
os = File(outputDir + ".decompiled").outputStream()
27+
os = File(outputDir + ".decompiled").outputStream(append = true)
2828
ps = new PrintStream(os)
2929
printToOutput(ps)
3030
} finally {

compiler/src/dotty/tools/dotc/decompiler/Main.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package dotty.tools.dotc.decompiler
22

3+
import java.nio.file.{Files, Paths}
4+
35
import dotty.tools.dotc
46
import dotty.tools.dotc.core.Contexts._
57

@@ -10,6 +12,9 @@ import dotty.tools.dotc.core.Contexts._
1012
object Main extends dotc.Driver {
1113
override protected def newCompiler(implicit ctx: Context): dotc.Compiler = {
1214
assert(ctx.settings.fromTasty.value)
15+
val outputDir = ctx.settings.outputDir.value
16+
if (outputDir != ".")
17+
Files.deleteIfExists(Paths.get(outputDir + ".decompiled"))
1318
new TASTYDecompiler
1419
}
1520

0 commit comments

Comments
 (0)