summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/Global.scala
diff options
context:
space:
mode:
authorSeth Tisue <seth@tisue.net>2015-09-24 21:57:24 -0400
committerSeth Tisue <seth@tisue.net>2015-09-25 11:36:15 -0400
commitdaead5063f9c030d4c13cc49d264e68cc4e13f34 (patch)
tree19694814ac546288368d1ae2c021e2806131e86a /src/compiler/scala/tools/nsc/Global.scala
parentefece9fdb5c268d5a1af5b44cdac198c19eaff87 (diff)
downloadscala-daead5063f9c030d4c13cc49d264e68cc4e13f34.tar.gz
scala-daead5063f9c030d4c13cc49d264e68cc4e13f34.tar.bz2
scala-daead5063f9c030d4c13cc49d264e68cc4e13f34.zip
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.)
Diffstat (limited to 'src/compiler/scala/tools/nsc/Global.scala')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala5
1 files changed, 4 insertions, 1 deletions
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 =>