diff --git a/compiler/src/dotty/tools/dotc/interactive/Interactive.scala b/compiler/src/dotty/tools/dotc/interactive/Interactive.scala index b2ef621e4441..c9133925405f 100644 --- a/compiler/src/dotty/tools/dotc/interactive/Interactive.scala +++ b/compiler/src/dotty/tools/dotc/interactive/Interactive.scala @@ -305,7 +305,7 @@ object Interactive { val buf = new mutable.ListBuffer[SourceTree] trees foreach { case SourceTree(topTree, source) => - (new untpd.TreeTraverser { + new untpd.TreeTraverser { override def traverse(tree: untpd.Tree)(implicit ctx: Context) = { tree match { case utree: untpd.NameTree if tree.hasType => @@ -324,7 +324,7 @@ object Interactive { traverseChildren(tree) } } - }).traverse(topTree) + }.traverse(topTree) } buf.toList diff --git a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala index 58c464de97f5..0215dc06b98e 100644 --- a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala +++ b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala @@ -128,17 +128,17 @@ class InteractiveDriver(val settings: List[String]) extends Driver { // Like in `ZipArchiveFileLookup` we assume that zips are immutable private val zipClassPathClasses: Seq[String] = zipClassPaths.flatMap { zipCp => - // Working with Java 8 stream without SAMs and scala-java8-compat is awful. - val entries = new ZipFile(zipCp.zipFile) - .stream - .toArray(new IntFunction[Array[ZipEntry]] { def apply(size: Int) = new Array(size) }) - .toSeq - for { - entry <- entries - name = entry.getName - tastySuffix <- tastySuffixes - if name.endsWith(tastySuffix) - } yield name.replace("/", ".").stripSuffix(tastySuffix) + val zipFile = new ZipFile(zipCp.zipFile) + + try { + for { + entry <- zipFile.stream.iterator().asScala + name = entry.getName + tastySuffix <- tastySuffixes + if name.endsWith(tastySuffix) + } yield name.replace("/", ".").stripSuffix(tastySuffix) + } + finally zipFile.close() } // FIXME: classfiles in directories may change at any point, so we retraverse diff --git a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala index 39cf3ed6d61c..4a10c2dc90bd 100644 --- a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala +++ b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala @@ -284,30 +284,28 @@ trait ParallelTesting extends RunnerOrchestration { self => } /** A single `Runnable` that prints a progress bar for the curent `Test` */ - private def createProgressMonitor: Runnable = new Runnable { - def run(): Unit = { - val start = System.currentTimeMillis - var tCompiled = testSourcesCompleted - while (tCompiled < sourceCount) { - val timestamp = (System.currentTimeMillis - start) / 1000 - val progress = (tCompiled.toDouble / sourceCount * 40).toInt - - realStdout.print( - "[" + ("=" * (math.max(progress - 1, 0))) + + private def createProgressMonitor: Runnable = () => { + val start = System.currentTimeMillis + var tCompiled = testSourcesCompleted + while (tCompiled < sourceCount) { + val timestamp = (System.currentTimeMillis - start) / 1000 + val progress = (tCompiled.toDouble / sourceCount * 40).toInt + + realStdout.print( + "[" + ("=" * (math.max(progress - 1, 0))) + (if (progress > 0) ">" else "") + (" " * (39 - progress)) + s"] completed ($tCompiled/$sourceCount, ${timestamp}s)\r" - ) - - Thread.sleep(100) - tCompiled = testSourcesCompleted - } - // println, otherwise no newline and cursor at start of line - realStdout.println( - s"[=======================================] completed ($sourceCount/$sourceCount, " + - s"${(System.currentTimeMillis - start) / 1000}s) " ) + + Thread.sleep(100) + tCompiled = testSourcesCompleted } + // println, otherwise no newline and cursor at start of line + realStdout.println( + s"[=======================================] completed ($sourceCount/$sourceCount, " + + s"${(System.currentTimeMillis - start) / 1000}s) " + ) } /** Wrapper function to make sure that the compiler itself did not crash - diff --git a/language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala b/language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala index f70310f21d30..fe8954760ddc 100644 --- a/language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala +++ b/language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala @@ -165,14 +165,9 @@ class DottyLanguageServer extends LanguageServer // Do most of the initialization asynchronously so that we can return early // from this method and thus let the client know our capabilities. CompletableFuture.supplyAsync(() => drivers) - .exceptionally { - // Can't use a function literal here because of #2367 - new Function[Throwable, Nothing] { - def apply(ex: Throwable) = { - ex.printStackTrace - sys.exit(1) - } - } + .exceptionally { (ex: Throwable) => + ex.printStackTrace + sys.exit(1) } new InitializeResult(c)