Merge branch 'wip/3648' into 1.x

This commit is contained in:
Eugene Yokota 2017-10-20 23:58:39 -05:00
commit bcd21ba9b6
23 changed files with 41 additions and 41 deletions

View File

@ -229,7 +229,9 @@ private class BasicAttributeMap(private val backing: Map[AttributeKey[_], Any])
} }
def entries: Iterable[AttributeEntry[_]] = def entries: Iterable[AttributeEntry[_]] =
for ((k: AttributeKey[kt], v) <- backing) yield AttributeEntry(k, v.asInstanceOf[kt]) backing.collect {
case (k: AttributeKey[kt], v) => AttributeEntry(k, v.asInstanceOf[kt])
}
private[sbt] def setCond[T](k: AttributeKey[T], opt: Option[T]): AttributeMap = private[sbt] def setCond[T](k: AttributeKey[T], opt: Option[T]): AttributeMap =
opt match { opt match {

View File

@ -41,7 +41,7 @@ object IDSet {
def +=(t: T) = { backing.put(t, Dummy); () } def +=(t: T) = { backing.put(t, Dummy); () }
def ++=(t: Iterable[T]) = t foreach += def ++=(t: Iterable[T]) = t foreach +=
def -=(t: T) = if (backing.remove(t) eq null) false else true def -=(t: T) = if (backing.remove(t) eq null) false else true
def all = collection.JavaConversions.collectionAsScalaIterable(backing.keySet) def all = collection.JavaConverters.collectionAsScalaIterable(backing.keySet)
def toList = all.toList def toList = all.toList
def isEmpty = backing.isEmpty def isEmpty = backing.isEmpty

View File

@ -793,7 +793,7 @@ trait Init[Scope] {
// proper solution is for evaluate to be deprecated or for external use only and a new internal method returning Either be used // proper solution is for evaluate to be deprecated or for external use only and a new internal method returning Either be used
private[this] def trapBadRef[A](run: => A): Option[A] = private[this] def trapBadRef[A](run: => A): Option[A] =
try Some(run) try Some(run)
catch { case e: InvalidReference => None } catch { case _: InvalidReference => None }
private[sbt] def processAttributes[B](init: B)(f: (B, AttributeMap) => B): B = a match { private[sbt] def processAttributes[B](init: B)(f: (B, AttributeMap) => B): B = a match {
case None => init case None => init

View File

@ -16,7 +16,7 @@ object Signals {
try { try {
val signals = new Signals0 val signals = new Signals0
signals.withHandler(signal, handler, action) signals.withHandler(signal, handler, action)
} catch { case e: LinkageError => Right(action()) } } catch { case _: LinkageError => Right(action()) }
result match { result match {
case Left(e) => throw e case Left(e) => throw e
@ -61,7 +61,7 @@ object Signals {
try { try {
val signals = new Signals0 val signals = new Signals0
signals.supported(signal) signals.supported(signal)
} catch { case e: LinkageError => false } } catch { case _: LinkageError => false }
} }
// Must only be referenced using a // Must only be referenced using a
@ -70,7 +70,7 @@ object Signals {
private final class Signals0 { private final class Signals0 {
def supported(signal: String): Boolean = { def supported(signal: String): Boolean = {
import sun.misc.Signal import sun.misc.Signal
try { new Signal(signal); true } catch { case e: IllegalArgumentException => false } try { new Signal(signal); true } catch { case _: IllegalArgumentException => false }
} }
// returns a LinkageError in `action` as Left(t) in order to avoid it being // returns a LinkageError in `action` as Left(t) in order to avoid it being

View File

@ -56,5 +56,5 @@ object History {
new History(lines.toIndexedSeq, path, sys.error) new History(lines.toIndexedSeq, path, sys.error)
def number(s: String): Option[Int] = def number(s: String): Option[Int] =
try { Some(s.toInt) } catch { case e: NumberFormatException => None } try { Some(s.toInt) } catch { case _: NumberFormatException => None }
} }

View File

@ -11,7 +11,7 @@ package complete
import jline.console.ConsoleReader import jline.console.ConsoleReader
import jline.console.completer.{ Completer, CompletionHandler } import jline.console.completer.{ Completer, CompletionHandler }
import scala.annotation.tailrec import scala.annotation.tailrec
import collection.JavaConversions import scala.collection.JavaConverters
object JLineCompletion { object JLineCompletion {
def installCustomCompletor(reader: ConsoleReader, parser: Parser[_]): Unit = def installCustomCompletor(reader: ConsoleReader, parser: Parser[_]): Unit =
@ -154,7 +154,7 @@ object JLineCompletion {
if (line.charAt(line.length - 1) != '\n') if (line.charAt(line.length - 1) != '\n')
reader.println() reader.println()
} }
reader.printColumns(JavaConversions.seqAsJavaList(columns.map(_.trim))) reader.printColumns(JavaConverters.seqAsJavaList(columns.map(_.trim)))
} }
def hasNewline(s: String): Boolean = s.indexOf('\n') >= 0 def hasNewline(s: String): Boolean = s.indexOf('\n') >= 0

View File

@ -280,7 +280,7 @@ object Parser extends ParserMain {
def checkRepeated(invalidButOptional: => Parser[Seq[T]]): Parser[Seq[T]] = def checkRepeated(invalidButOptional: => Parser[Seq[T]]): Parser[Seq[T]] =
repeated match { repeated match {
case i: Invalid if min == 0 => invalidButOptional case _: Invalid if min == 0 => invalidButOptional
case i: Invalid => i case i: Invalid => i
case _ => case _ =>
repeated.result match { repeated.result match {
@ -327,9 +327,7 @@ trait ParserMain {
def !!!(msg: String): Parser[A] = onFailure(a, msg) def !!!(msg: String): Parser[A] = onFailure(a, msg)
def failOnException: Parser[A] = trapAndFail(a) def failOnException: Parser[A] = trapAndFail(a)
def unary_- = not(a, "Unexpected: " + a)
def &(o: Parser[_]) = and(a, o) def &(o: Parser[_]) = and(a, o)
def -(o: Parser[_]) = and(a, not(o, "Unexpected: " + o))
def examples(s: String*): Parser[A] = examples(s.toSet) def examples(s: String*): Parser[A] = examples(s.toSet)
def examples(s: Set[String], check: Boolean = false): Parser[A] = def examples(s: Set[String], check: Boolean = false): Parser[A] =
@ -578,7 +576,7 @@ trait ParserMain {
case (Invalid(af), Invalid(bf)) => Invalid(af ++ bf) case (Invalid(af), Invalid(bf)) => Invalid(af ++ bf)
case (Invalid(_), bv) => bv case (Invalid(_), bv) => bv
case (av, Invalid(_)) => av case (av, Invalid(_)) => av
case (av, bv) => new HomParser(a, b) case (_, _) => new HomParser(a, b)
} }
def not(p: Parser[_], failMessage: String): Parser[Unit] = p.result match { def not(p: Parser[_], failMessage: String): Parser[Unit] = p.result match {
@ -631,7 +629,7 @@ private final case class SoftInvalid(fail: Failure) extends ValidParser[Nothing]
} }
private final class TrapAndFail[A](a: Parser[A]) extends ValidParser[A] { private final class TrapAndFail[A](a: Parser[A]) extends ValidParser[A] {
def result = try { a.result } catch { case e: Exception => None } def result = try { a.result } catch { case _: Exception => None }
def resultEmpty = try { a.resultEmpty } catch { case e: Exception => fail(e) } def resultEmpty = try { a.resultEmpty } catch { case e: Exception => fail(e) }
def derive(c: Char) = try { trapAndFail(a derive c) } catch { def derive(c: Char) = try { trapAndFail(a derive c) } catch {
@ -639,7 +637,7 @@ private final class TrapAndFail[A](a: Parser[A]) extends ValidParser[A] {
} }
def completions(level: Int) = try { a.completions(level) } catch { def completions(level: Int) = try { a.completions(level) } catch {
case e: Exception => Completions.nil case _: Exception => Completions.nil
} }
override def toString = "trap(" + a + ")" override def toString = "trap(" + a + ")"
@ -651,7 +649,7 @@ private final class OnFailure[A](a: Parser[A], message: String) extends ValidPar
def result = a.result def result = a.result
def resultEmpty = a.resultEmpty match { def resultEmpty = a.resultEmpty match {
case f: Failure => mkFailure(message); case v: Value[A] => v case _: Failure => mkFailure(message); case v: Value[A] => v
} }
def derive(c: Char) = onFailure(a derive c, message) def derive(c: Char) = onFailure(a derive c, message)
@ -685,7 +683,7 @@ private final class HomParser[A](a: Parser[A], b: Parser[A]) extends ValidParser
} }
private final class HetParser[A, B](a: Parser[A], b: Parser[B]) extends ValidParser[Either[A, B]] { private final class HetParser[A, B](a: Parser[A], b: Parser[B]) extends ValidParser[Either[A, B]] {
lazy val result = tuple(a.result, b.result) map { case (a, b) => Left(a) } lazy val result = tuple(a.result, b.result) map { case (a, _) => Left(a) }
def derive(c: Char) = (a derive c) || (b derive c) def derive(c: Char) = (a derive c) || (b derive c)
lazy val resultEmpty = a.resultEmpty either b.resultEmpty lazy val resultEmpty = a.resultEmpty either b.resultEmpty
def completions(level: Int) = a.completions(level) ++ b.completions(level) def completions(level: Int) = a.completions(level) ++ b.completions(level)
@ -699,7 +697,7 @@ private final class ParserSeq[T](a: Seq[Parser[T]], errors: => Seq[String])
lazy val resultEmpty: Result[Seq[T]] = { lazy val resultEmpty: Result[Seq[T]] = {
val res = a.map(_.resultEmpty) val res = a.map(_.resultEmpty)
val (failures, values) = separate(res)(_.toEither) val (failures, values) = separate(res)(_.toEither)
// if(failures.isEmpty) Value(values) else mkFailures(failures.flatMap(_()) ++ errors) // if(failures.isEmpty) Value(values) else mkFailures(failures.flatMap(_()) ++ errors)
if (values.nonEmpty) Value(values) else mkFailures(failures.flatMap(_()) ++ errors) if (values.nonEmpty) Value(values) else mkFailures(failures.flatMap(_()) ++ errors)
} }
@ -808,8 +806,8 @@ private final class Not(delegate: Parser[_], failMessage: String) extends ValidP
def result = None def result = None
lazy val resultEmpty = delegate.resultEmpty match { lazy val resultEmpty = delegate.resultEmpty match {
case f: Failure => Value(()) case _: Failure => Value(())
case v: Value[_] => mkFailure(failMessage) case _: Value[_] => mkFailure(failMessage)
} }
override def toString = " -(%s)".format(delegate) override def toString = " -(%s)".format(delegate)

View File

@ -32,7 +32,7 @@ private[sbt] object TypeString {
def cleanup(typeString: String): String = def cleanup(typeString: String): String =
parse(typeString, typeStringParser) match { parse(typeString, typeStringParser) match {
case Right(ts) => ts.toString case Right(ts) => ts.toString
case Left(err) => typeString case Left(_) => typeString
} }
/** /**

View File

@ -71,7 +71,7 @@ object Sync {
def noDuplicateTargets(relation: Relation[File, File]): Unit = { def noDuplicateTargets(relation: Relation[File, File]): Unit = {
val dups = relation.reverseMap.filter { val dups = relation.reverseMap.filter {
case (target, srcs) => case (_, srcs) =>
srcs.size >= 2 && srcs.exists(!_.isDirectory) srcs.size >= 2 && srcs.exists(!_.isDirectory)
} map { } map {
case (target, srcs) => case (target, srcs) =>

View File

@ -136,7 +136,7 @@ object TestResultLogger {
pendingCount) = pendingCount) =
results.events.foldLeft((0, 0, 0, 0, 0, 0, 0)) { results.events.foldLeft((0, 0, 0, 0, 0, 0, 0)) {
case ((skippedAcc, errorAcc, passedAcc, failureAcc, ignoredAcc, canceledAcc, pendingAcc), case ((skippedAcc, errorAcc, passedAcc, failureAcc, ignoredAcc, canceledAcc, pendingAcc),
(name, testEvent)) => (name @ _, testEvent)) =>
(skippedAcc + testEvent.skippedCount, (skippedAcc + testEvent.skippedCount,
errorAcc + testEvent.errorCount, errorAcc + testEvent.errorCount,
passedAcc + testEvent.passedCount, passedAcc + testEvent.passedCount,

View File

@ -157,7 +157,7 @@ object Tests {
case Listeners(listeners) => testListeners ++= listeners case Listeners(listeners) => testListeners ++= listeners
case Setup(setupFunction) => setup += setupFunction case Setup(setupFunction) => setup += setupFunction
case Cleanup(cleanupFunction) => cleanup += cleanupFunction case Cleanup(cleanupFunction) => cleanup += cleanupFunction
case a: Argument => // now handled by whatever constructs `runners` case _: Argument => // now handled by whatever constructs `runners`
} }
} }

View File

@ -46,7 +46,7 @@ private[sbt] final class ConsoleChannel(val name: String) extends CommandChannel
event match { event match {
case e: ConsolePromptEvent => case e: ConsolePromptEvent =>
askUserThread match { askUserThread match {
case Some(x) => // case Some(_) =>
case _ => case _ =>
val x = makeAskUserThread(e.state) val x = makeAskUserThread(e.state)
askUserThread = Some(x) askUserThread = Some(x)
@ -56,7 +56,7 @@ private[sbt] final class ConsoleChannel(val name: String) extends CommandChannel
e.lastSource match { e.lastSource match {
case Some(src) if src.channelName != name => case Some(src) if src.channelName != name =>
askUserThread match { askUserThread match {
case Some(x) => case Some(_) =>
// keep listening while network-origin command is running // keep listening while network-origin command is running
// make sure to test Windows and Cygwin, if you uncomment // make sure to test Windows and Cygwin, if you uncomment
// shutdown() // shutdown()

View File

@ -111,7 +111,7 @@ class NetworkClient(arguments: List[String]) { self =>
try { try {
connection.publish(bytes) connection.publish(bytes)
} catch { } catch {
case e: SocketException => case _: SocketException =>
// log.debug(e.getMessage) // log.debug(e.getMessage)
// toDel += client // toDel += client
} }

View File

@ -31,7 +31,7 @@ object IPC {
def createServer(attempts: Int): ServerSocket = def createServer(attempts: Int): ServerSocket =
if (attempts > 0) if (attempts > 0)
try { new ServerSocket(nextPort, 1, loopback) } catch { try { new ServerSocket(nextPort, 1, loopback) } catch {
case NonFatal(e) => createServer(attempts - 1) case NonFatal(_) => createServer(attempts - 1)
} else } else
sys.error("Could not connect to socket: maximum attempts exceeded") sys.error("Could not connect to socket: maximum attempts exceeded")
createServer(10) createServer(10)

View File

@ -275,7 +275,7 @@ object Scope {
case Select(conf) => index.config(configProj, conf); case _ => withZeroAxis(scope.config) case Select(conf) => index.config(configProj, conf); case _ => withZeroAxis(scope.config)
} }
val tLin = scope.task match { val tLin = scope.task match {
case t @ Select(task) => linearize(t)(taskInherit); case _ => withZeroAxis(scope.task) case t @ Select(_) => linearize(t)(taskInherit); case _ => withZeroAxis(scope.task)
} }
val eLin = withZeroAxis(scope.extra) val eLin = withZeroAxis(scope.extra)
for (c <- cLin; t <- tLin; e <- eLin) yield Scope(px, c, t, e) for (c <- cLin; t <- tLin; e <- eLin) yield Scope(px, c, t, e)

View File

@ -48,7 +48,7 @@ object Util {
"-Yno-adapted-args", "-Yno-adapted-args",
"-Ywarn-dead-code", "-Ywarn-dead-code",
"-Ywarn-numeric-widen", "-Ywarn-numeric-widen",
"-Ywarn-unused", "-Ywarn-unused:-patvars,-params,-implicits,_",
"-Ywarn-unused-import" "-Ywarn-unused-import"
) )
}), }),

View File

@ -24,7 +24,7 @@ trait JsonRpcRequestMessageFormats {
val id = try { val id = try {
unbuilder.readField[String]("id") unbuilder.readField[String]("id")
} catch { } catch {
case _ => unbuilder.readField[Long]("id").toString case _: Throwable => unbuilder.readField[Long]("id").toString
} }
val method = unbuilder.readField[String]("method") val method = unbuilder.readField[String]("method")
val params = unbuilder.lookupField("params") map { val params = unbuilder.lookupField("params") map {

View File

@ -27,7 +27,7 @@ trait JsonRpcResponseMessageFormats {
val id = try { val id = try {
unbuilder.readField[Option[String]]("id") unbuilder.readField[Option[String]]("id")
} catch { } catch {
case _ => unbuilder.readField[Option[Long]]("id") map { _.toString } case _: Throwable => unbuilder.readField[Option[Long]]("id") map { _.toString }
} }
val result = unbuilder.lookupField("result") map { val result = unbuilder.lookupField("result") map {

View File

@ -38,7 +38,7 @@ class ForkRun(config: ForkOptions) extends ScalaRun {
1 1
} }
val exitCode = try process.exitValue() val exitCode = try process.exitValue()
catch { case e: InterruptedException => cancel() } catch { case _: InterruptedException => cancel() }
processExitCode(exitCode, "runner") processExitCode(exitCode, "runner")
} }

View File

@ -162,7 +162,7 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM
executionThread.start() // thread actually evaluating `f` executionThread.start() // thread actually evaluating `f`
finish(app, log) finish(app, log)
} catch { } catch {
case e: InterruptedException => // here, the thread that started the run has been interrupted, not the main thread of the executing code case _: InterruptedException => // here, the thread that started the run has been interrupted, not the main thread of the executing code
cancel(executionThread, app, log) cancel(executionThread, app, log)
} finally app.cleanup() } finally app.cleanup()
} }

View File

@ -36,7 +36,7 @@ final class SbtHandler(directory: File,
def onSbtInstance(i: Option[SbtInstance])(f: (Process, IPC.Server) => Unit): Option[SbtInstance] = def onSbtInstance(i: Option[SbtInstance])(f: (Process, IPC.Server) => Unit): Option[SbtInstance] =
i match { i match {
case Some(ai @ SbtInstance(process, server)) if server.isClosed => case Some(SbtInstance(_, server)) if server.isClosed =>
finish(i) finish(i)
onNewSbtInstance(f) onNewSbtInstance(f)
case Some(SbtInstance(process, server)) => case Some(SbtInstance(process, server)) =>
@ -66,7 +66,7 @@ final class SbtHandler(directory: File,
send("exit", server) send("exit", server)
process.exitValue() process.exitValue()
} catch { } catch {
case e: IOException => process.destroy() case _: IOException => process.destroy()
} }
case None => case None =>
} }
@ -85,7 +85,7 @@ final class SbtHandler(directory: File,
val thread = new Thread() { override def run() = { p.exitValue(); server.close() } } val thread = new Thread() { override def run() = { p.exitValue(); server.close() } }
thread.start() thread.start()
try { receive("Remote sbt initialization failed", server) } catch { try { receive("Remote sbt initialization failed", server) } catch {
case e: java.net.SocketException => throw new TestFailed("Remote sbt initialization failed") case _: java.net.SocketException => throw new TestFailed("Remote sbt initialization failed")
} }
p p
} }

View File

@ -165,7 +165,7 @@ trait TaskExtra {
Result.tryValues[S](tx :: Nil, x) Result.tryValues[S](tx :: Nil, x)
}) })
def ||[T >: S](alt: Task[T]): Task[T] = flatMapR { def ||[T >: S](alt: Task[T]): Task[T] = flatMapR {
case Value(v) => task(v); case Inc(i) => alt case Value(v) => task(v); case Inc(_) => alt
} }
def &&[T](alt: Task[T]): Task[T] = flatMap(_ => alt) def &&[T](alt: Task[T]): Task[T] = flatMap(_ => alt)
} }
@ -242,7 +242,7 @@ object TaskExtra extends TaskExtra {
case Seq() => sys.error("Cannot reduce empty sequence") case Seq() => sys.error("Cannot reduce empty sequence")
case Seq(x) => x case Seq(x) => x
case Seq(x, y) => reducePair(x, y, f) case Seq(x, y) => reducePair(x, y, f)
case z => case _ =>
val (a, b) = i.splitAt(i.size / 2) val (a, b) = i.splitAt(i.size / 2)
reducePair(reduced(a, f), reduced(b, f), f) reducePair(reduced(a, f), reduced(b, f), f)
} }
@ -254,7 +254,7 @@ object TaskExtra extends TaskExtra {
val incs = failuresM(a)(in) val incs = failuresM(a)(in)
if (incs.isEmpty) expectedFailure else incs if (incs.isEmpty) expectedFailure else incs
} }
def failM[T]: Result[T] => Incomplete = { case Inc(i) => i; case x => expectedFailure } def failM[T]: Result[T] => Incomplete = { case Inc(i) => i; case _ => expectedFailure }
def expectedFailure = throw Incomplete(None, message = Some("Expected dependency to fail.")) def expectedFailure = throw Incomplete(None, message = Some("Expected dependency to fail."))

View File

@ -34,7 +34,7 @@ class JUnitXmlTestsListener(val outputDir: String) extends TestsListener {
val hostname = val hostname =
try InetAddress.getLocalHost.getHostName try InetAddress.getLocalHost.getHostName
catch { catch {
case x: IOException => "localhost" case _: IOException => "localhost"
} }
/**The dir in which we put all result files. Is equal to the given dir + "/test-reports"*/ /**The dir in which we put all result files. Is equal to the given dir + "/test-reports"*/