Skip to content

Commit 04ed0d1

Browse files
author
Rajesh Veeranki
committed
Fix #2967: Adapt Vulpix, InteractiveDriver to SAM types
1 parent d70b8f4 commit 04ed0d1

File tree

4 files changed

+24
-34
lines changed

4 files changed

+24
-34
lines changed

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

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

153153
trees foreach { case SourceTree(topTree, source) =>
154-
(new untpd.TreeTraverser {
154+
new untpd.TreeTraverser {
155155
override def traverse(tree: untpd.Tree)(implicit ctx: Context) = {
156156
tree match {
157157
case _: untpd.Inlined =>
@@ -169,7 +169,7 @@ object Interactive {
169169
}
170170
traverseChildren(tree)
171171
}
172-
}).traverse(topTree)
172+
}.traverse(topTree)
173173
}
174174

175175
buf.toList

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

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

123123
// Like in `ZipArchiveFileLookup` we assume that zips are immutable
124124
private val zipClassPathClasses: Seq[String] = zipClassPaths.flatMap { zipCp =>
125-
// Working with Java 8 stream without SAMs and scala-java8-compat is awful.
126-
val entries = new ZipFile(zipCp.zipFile)
125+
new ZipFile(zipCp.zipFile)
127126
.stream
128-
.toArray(new IntFunction[Array[ZipEntry]] { def apply(size: Int) = new Array(size) })
129-
.toSeq
130-
for {
131-
entry <- entries
132-
name = entry.getName
133-
tastySuffix <- tastySuffixes
134-
if name.endsWith(tastySuffix)
135-
} yield name.replace("/", ".").stripSuffix(tastySuffix)
127+
.toArray((size: Int) => new Array[ZipEntry](size))
128+
.map((e: ZipEntry) => e.getName)
129+
.flatMap((name: String) => tastySuffixes.find(name.endsWith).map(name.replace("/", ".").stripSuffix))
136130
}
137131

138132
// 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
@@ -288,30 +288,28 @@ trait ParallelTesting extends RunnerOrchestration { self =>
288288
}
289289

290290
/** A single `Runnable` that prints a progress bar for the curent `Test` */
291-
private def createProgressMonitor: Runnable = new Runnable {
292-
def run(): Unit = {
293-
val start = System.currentTimeMillis
294-
var tCompiled = testSourcesCompleted
295-
while (tCompiled < sourceCount) {
296-
val timestamp = (System.currentTimeMillis - start) / 1000
297-
val progress = (tCompiled.toDouble / sourceCount * 40).toInt
298-
299-
realStdout.print(
300-
"[" + ("=" * (math.max(progress - 1, 0))) +
291+
private def createProgressMonitor: Runnable = () => {
292+
val start = System.currentTimeMillis
293+
var tCompiled = testSourcesCompleted
294+
while (tCompiled < sourceCount) {
295+
val timestamp = (System.currentTimeMillis - start) / 1000
296+
val progress = (tCompiled.toDouble / sourceCount * 40).toInt
297+
298+
realStdout.print(
299+
"[" + ("=" * (math.max(progress - 1, 0))) +
301300
(if (progress > 0) ">" else "") +
302301
(" " * (39 - progress)) +
303302
s"] completed ($tCompiled/$sourceCount, ${timestamp}s)\r"
304-
)
305-
306-
Thread.sleep(100)
307-
tCompiled = testSourcesCompleted
308-
}
309-
// println, otherwise no newline and cursor at start of line
310-
realStdout.println(
311-
s"[=======================================] completed ($sourceCount/$sourceCount, " +
312-
s"${(System.currentTimeMillis - start) / 1000}s) "
313303
)
304+
305+
Thread.sleep(100)
306+
tCompiled = testSourcesCompleted
314307
}
308+
// println, otherwise no newline and cursor at start of line
309+
realStdout.println(
310+
s"[=======================================] completed ($sourceCount/$sourceCount, " +
311+
s"${(System.currentTimeMillis - start) / 1000}s) "
312+
)
315313
}
316314

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

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,10 @@ class DottyLanguageServer extends LanguageServer
136136
CompletableFuture.supplyAsync(() => drivers)
137137
.exceptionally {
138138
// Can't use a function literal here because of #2367
139-
new Function[Throwable, Nothing] {
140-
def apply(ex: Throwable) = {
139+
(ex: Throwable) => {
141140
ex.printStackTrace
142141
sys.exit(1)
143142
}
144-
}
145143
}
146144

147145
new InitializeResult(c)

0 commit comments

Comments
 (0)