Skip to content

Commit c71f4d8

Browse files
authored
Merge pull request #3010 from Rajesh-Veeranki/fix-2967
Fix #2967: Adapt Vulpix, InteractiveDriver to SAM types
2 parents 0448afc + 0ae6f04 commit c71f4d8

File tree

4 files changed

+33
-40
lines changed

4 files changed

+33
-40
lines changed

compiler/src/dotty/tools/dotc/interactive/Interactive.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ object Interactive {
305305
val buf = new mutable.ListBuffer[SourceTree]
306306

307307
trees foreach { case SourceTree(topTree, source) =>
308-
(new untpd.TreeTraverser {
308+
new untpd.TreeTraverser {
309309
override def traverse(tree: untpd.Tree)(implicit ctx: Context) = {
310310
tree match {
311311
case utree: untpd.NameTree if tree.hasType =>
@@ -324,7 +324,7 @@ object Interactive {
324324
traverseChildren(tree)
325325
}
326326
}
327-
}).traverse(topTree)
327+
}.traverse(topTree)
328328
}
329329

330330
buf.toList

compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,17 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
128128

129129
// Like in `ZipArchiveFileLookup` we assume that zips are immutable
130130
private val zipClassPathClasses: Seq[String] = zipClassPaths.flatMap { zipCp =>
131-
// Working with Java 8 stream without SAMs and scala-java8-compat is awful.
132-
val entries = new ZipFile(zipCp.zipFile)
133-
.stream
134-
.toArray(new IntFunction[Array[ZipEntry]] { def apply(size: Int) = new Array(size) })
135-
.toSeq
136-
for {
137-
entry <- entries
138-
name = entry.getName
139-
tastySuffix <- tastySuffixes
140-
if name.endsWith(tastySuffix)
141-
} yield name.replace("/", ".").stripSuffix(tastySuffix)
131+
val zipFile = new ZipFile(zipCp.zipFile)
132+
133+
try {
134+
for {
135+
entry <- zipFile.stream.iterator().asScala
136+
name = entry.getName
137+
tastySuffix <- tastySuffixes
138+
if name.endsWith(tastySuffix)
139+
} yield name.replace("/", ".").stripSuffix(tastySuffix)
140+
}
141+
finally zipFile.close()
142142
}
143143

144144
// FIXME: classfiles in directories may change at any point, so we retraverse

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -284,30 +284,28 @@ trait ParallelTesting extends RunnerOrchestration { self =>
284284
}
285285

286286
/** A single `Runnable` that prints a progress bar for the curent `Test` */
287-
private def createProgressMonitor: Runnable = new Runnable {
288-
def run(): Unit = {
289-
val start = System.currentTimeMillis
290-
var tCompiled = testSourcesCompleted
291-
while (tCompiled < sourceCount) {
292-
val timestamp = (System.currentTimeMillis - start) / 1000
293-
val progress = (tCompiled.toDouble / sourceCount * 40).toInt
294-
295-
realStdout.print(
296-
"[" + ("=" * (math.max(progress - 1, 0))) +
287+
private def createProgressMonitor: Runnable = () => {
288+
val start = System.currentTimeMillis
289+
var tCompiled = testSourcesCompleted
290+
while (tCompiled < sourceCount) {
291+
val timestamp = (System.currentTimeMillis - start) / 1000
292+
val progress = (tCompiled.toDouble / sourceCount * 40).toInt
293+
294+
realStdout.print(
295+
"[" + ("=" * (math.max(progress - 1, 0))) +
297296
(if (progress > 0) ">" else "") +
298297
(" " * (39 - progress)) +
299298
s"] completed ($tCompiled/$sourceCount, ${timestamp}s)\r"
300-
)
301-
302-
Thread.sleep(100)
303-
tCompiled = testSourcesCompleted
304-
}
305-
// println, otherwise no newline and cursor at start of line
306-
realStdout.println(
307-
s"[=======================================] completed ($sourceCount/$sourceCount, " +
308-
s"${(System.currentTimeMillis - start) / 1000}s) "
309299
)
300+
301+
Thread.sleep(100)
302+
tCompiled = testSourcesCompleted
310303
}
304+
// println, otherwise no newline and cursor at start of line
305+
realStdout.println(
306+
s"[=======================================] completed ($sourceCount/$sourceCount, " +
307+
s"${(System.currentTimeMillis - start) / 1000}s) "
308+
)
311309
}
312310

313311
/** Wrapper function to make sure that the compiler itself did not crash -

language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,9 @@ class DottyLanguageServer extends LanguageServer
165165
// Do most of the initialization asynchronously so that we can return early
166166
// from this method and thus let the client know our capabilities.
167167
CompletableFuture.supplyAsync(() => drivers)
168-
.exceptionally {
169-
// Can't use a function literal here because of #2367
170-
new Function[Throwable, Nothing] {
171-
def apply(ex: Throwable) = {
172-
ex.printStackTrace
173-
sys.exit(1)
174-
}
175-
}
168+
.exceptionally { (ex: Throwable) =>
169+
ex.printStackTrace
170+
sys.exit(1)
176171
}
177172

178173
new InitializeResult(c)

0 commit comments

Comments
 (0)