Skip to content

Commit ff519cd

Browse files
Rajesh Veerankiallanrenucci
Rajesh Veeranki
authored andcommitted
Fix scala#2967: Adapt Vulpix, InteractiveDriver to SAM types
1 parent 88d016c commit ff519cd

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
@@ -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
@@ -282,30 +282,28 @@ trait ParallelTesting extends RunnerOrchestration { self =>
282282
}
283283

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

311309
/** 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
@@ -135,13 +135,10 @@ class DottyLanguageServer extends LanguageServer
135135
// from this method and thus let the client know our capabilities.
136136
CompletableFuture.supplyAsync(() => drivers)
137137
.exceptionally {
138-
// Can't use a function literal here because of #2367
139-
new Function[Throwable, Nothing] {
140-
def apply(ex: Throwable) = {
138+
(ex: Throwable) => {
141139
ex.printStackTrace
142140
sys.exit(1)
143141
}
144-
}
145142
}
146143

147144
new InitializeResult(c)

0 commit comments

Comments
 (0)