From daead5063f9c030d4c13cc49d264e68cc4e13f34 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Thu, 24 Sep 2015 21:57:24 -0400 Subject: fix bug where -Xprint-icode leaked an InputStream and a file handle usually it hardly matters, but it's still a bug, and on Windows we can't delete an open file, so this can cause trouble for someone writing a test that relies on being able to generate icode files and then clean them up afterwards. (and in fact, two IcodeComparison-based tests were failing.) --- src/compiler/scala/tools/nsc/Global.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/compiler/scala/tools/nsc/Global.scala') diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 3469726455..936bed7c8f 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -1686,7 +1686,10 @@ class Global(var currentSettings: Settings, var reporter: Reporter) try { val stream = new FileOutputStream(file) printer.setWriter(new PrintWriter(stream, true)) - printer.printClass(cls) + try + printer.printClass(cls) + finally + stream.close() informProgress(s"wrote $file") } catch { case e: IOException => -- cgit v1.2.3