Skip to content

Commit 169da6d

Browse files
Rajesh Veerankiallanrenucci
Rajesh Veeranki
authored andcommitted
Fix #2967: Adapt Vulpix, InteractiveDriver to SAM types
1 parent d72323e commit 169da6d

File tree

4 files changed

+24
-35
lines changed

4 files changed

+24
-35
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: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,11 @@ 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)
131+
new ZipFile(zipCp.zipFile)
133132
.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)
133+
.toArray((size: Int) => new Array[ZipEntry](size))
134+
.map((e: ZipEntry) => e.getName)
135+
.flatMap((name: String) => tastySuffixes.find(name.endsWith).map(name.replace("/", ".").stripSuffix))
142136
}
143137

144138
// 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: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,10 @@ class DottyLanguageServer extends LanguageServer
166166
// from this method and thus let the client know our capabilities.
167167
CompletableFuture.supplyAsync(() => drivers)
168168
.exceptionally {
169-
// Can't use a function literal here because of #2367
170-
new Function[Throwable, Nothing] {
171-
def apply(ex: Throwable) = {
169+
(ex: Throwable) => {
172170
ex.printStackTrace
173171
sys.exit(1)
174172
}
175-
}
176173
}
177174

178175
new InitializeResult(c)

0 commit comments

Comments
 (0)