From 6603a948474be2fa562e47fa521b568100ce9c83 Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Mon, 31 Aug 2015 10:55:02 +0200 Subject: [PATCH 1/2] Add sbt-houserules, formatting. --- .../src/test/scala/SettingsExample.scala | 3 +-- .../src/test/scala/SettingsTest.scala | 9 +++------ .../scala/sbt/complete/HistoryCommands.scala | 3 +-- .../src/main/scala/sbt/complete/TypeString.scala | 3 +-- .../sbt/complete/ParserWithExamplesTest.scala | 16 ++++++---------- .../src/main/scala/sbt/ExitHook.scala | 3 +-- .../src/main/scala/sbt/logic/Logic.scala | 3 +-- .../src/test/scala/sbt/logic/Test.scala | 3 +-- project/p.sbt | 1 + 9 files changed, 16 insertions(+), 28 deletions(-) create mode 100644 project/p.sbt diff --git a/internal/util-collection/src/test/scala/SettingsExample.scala b/internal/util-collection/src/test/scala/SettingsExample.scala index b48bb27fc..3a6bc3853 100644 --- a/internal/util-collection/src/test/scala/SettingsExample.scala +++ b/internal/util-collection/src/test/scala/SettingsExample.scala @@ -49,8 +49,7 @@ object SettingsUsage { val mySettings: Seq[Setting[_]] = Seq( setting(a3, value(3)), setting(b4, map(a4)(_ * 3)), - update(a5)(_ + 1) - ) + update(a5)(_ + 1)) // "compiles" and applies the settings. // This can be split into multiple steps to access intermediate results if desired. diff --git a/internal/util-collection/src/test/scala/SettingsTest.scala b/internal/util-collection/src/test/scala/SettingsTest.scala index d97b1056a..ab92332db 100644 --- a/internal/util-collection/src/test/scala/SettingsTest.scala +++ b/internal/util-collection/src/test/scala/SettingsTest.scala @@ -55,8 +55,7 @@ object SettingsTest extends Properties("settings") { List(scoped0, scoped1) <- chk :: scopedKeys sliding 2 nextInit = if (scoped0 == chk) chk else (scoped0 zipWith chk) { (p, _) => p + 1 } - } yield derive(setting(scoped1, nextInit)) - ).toSeq + } yield derive(setting(scoped1, nextInit))).toSeq { // Note: This causes a cycle refernec error, quite frequently. @@ -96,8 +95,7 @@ object SettingsTest extends Properties("settings") { setting(b, value(6)), derive(setting(b, a)), setting(a, value(5)), - setting(b, value(8)) - ) + setting(b, value(8))) val ev = evaluate(settings) checkKey(a, Some(5), ev) && checkKey(b, Some(8), ev) } @@ -106,8 +104,7 @@ object SettingsTest extends Properties("settings") { setting(a, value(3)), setting(b, value(6)), derive(setting(b, a)), - setting(a, value(5)) - ) + setting(a, value(5))) val ev = evaluate(settings) checkKey(a, Some(5), ev) && checkKey(b, Some(5), ev) } diff --git a/internal/util-complete/src/main/scala/sbt/complete/HistoryCommands.scala b/internal/util-complete/src/main/scala/sbt/complete/HistoryCommands.scala index c82ecfa3d..ff58fe9d2 100644 --- a/internal/util-complete/src/main/scala/sbt/complete/HistoryCommands.scala +++ b/internal/util-complete/src/main/scala/sbt/complete/HistoryCommands.scala @@ -34,8 +34,7 @@ object HistoryCommands { Nth -> ("Execute the command with index n, as shown by the " + ListFull + " command"), Previous -> "Execute the nth command before this one", StartsWithString -> "Execute the most recent command starting with 'string'", - ContainsString -> "Execute the most recent command containing 'string'" - ) + ContainsString -> "Execute the most recent command containing 'string'") def helpString = "History commands:\n " + (descriptions.map { case (c, d) => c + " " + d }).mkString("\n ") def printHelp(): Unit = println(helpString) diff --git a/internal/util-complete/src/main/scala/sbt/complete/TypeString.scala b/internal/util-complete/src/main/scala/sbt/complete/TypeString.scala index 6bf89ac05..bd5f84f43 100644 --- a/internal/util-complete/src/main/scala/sbt/complete/TypeString.scala +++ b/internal/util-complete/src/main/scala/sbt/complete/TypeString.scala @@ -61,8 +61,7 @@ private[sbt] object TypeString { val TypeMap = Map( "java.io.File" -> "File", "java.net.URL" -> "URL", - "java.net.URI" -> "URI" - ) + "java.net.URI" -> "URI") /** * A Parser that extracts basic structure from the string representation of a type from Manifest.toString. diff --git a/internal/util-complete/src/test/scala/sbt/complete/ParserWithExamplesTest.scala b/internal/util-complete/src/test/scala/sbt/complete/ParserWithExamplesTest.scala index dff68803c..3bcc55dd2 100644 --- a/internal/util-complete/src/test/scala/sbt/complete/ParserWithExamplesTest.scala +++ b/internal/util-complete/src/test/scala/sbt/complete/ParserWithExamplesTest.scala @@ -17,8 +17,7 @@ class ParserWithExamplesTest extends Specification { "use the delegate parser to remove invalid examples" in new parserWithValidExamples { val validCompletions = Completions(Set( suggestion("blue"), - suggestion("red") - )) + suggestion("red"))) parserWithExamples.completions(0) shouldEqual validCompletions } } @@ -26,8 +25,7 @@ class ParserWithExamplesTest extends Specification { "listing valid completions in a derived parser" should { "produce only valid examples that start with the character of the derivation" in new parserWithValidExamples { val derivedCompletions = Completions(Set( - suggestion("lue") - )) + suggestion("lue"))) parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions } } @@ -43,8 +41,7 @@ class ParserWithExamplesTest extends Specification { "produce only examples that start with the character of the derivation" in new parserWithAllExamples { val derivedCompletions = Completions(Set( suggestion("lue"), - suggestion("lock") - )) + suggestion("lock"))) parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions } } @@ -56,8 +53,8 @@ class ParserWithExamplesTest extends Specification { class parserWithAllExamples extends parser(removeInvalidExamples = false) case class parser(examples: Iterable[String] = Set("blue", "yellow", "greeen", "block", "red"), - maxNumberOfExamples: Int = 25, - removeInvalidExamples: Boolean) extends Scope { + maxNumberOfExamples: Int = 25, + removeInvalidExamples: Boolean) extends Scope { import DefaultParsers._ @@ -66,8 +63,7 @@ class ParserWithExamplesTest extends Specification { colorParser, FixedSetExamples(examples), maxNumberOfExamples, - removeInvalidExamples - ) + removeInvalidExamples) } case class GrowableSourceOfExamples() extends Iterable[String] { diff --git a/internal/util-control/src/main/scala/sbt/ExitHook.scala b/internal/util-control/src/main/scala/sbt/ExitHook.scala index 8ee5ddf86..16f295c7c 100644 --- a/internal/util-control/src/main/scala/sbt/ExitHook.scala +++ b/internal/util-control/src/main/scala/sbt/ExitHook.scala @@ -16,6 +16,5 @@ object ExitHooks { /** Calls each registered exit hook, trapping any exceptions so that each hook is given a chance to run. */ def runExitHooks(exitHooks: Seq[ExitHook]): Seq[Throwable] = exitHooks.flatMap(hook => - ErrorHandling.wideConvert(hook.runBeforeExiting()).left.toOption - ) + ErrorHandling.wideConvert(hook.runBeforeExiting()).left.toOption) } \ No newline at end of file diff --git a/internal/util-logic/src/main/scala/sbt/logic/Logic.scala b/internal/util-logic/src/main/scala/sbt/logic/Logic.scala index 856394251..0fbbe3f98 100644 --- a/internal/util-logic/src/main/scala/sbt/logic/Logic.scala +++ b/internal/util-logic/src/main/scala/sbt/logic/Logic.scala @@ -103,8 +103,7 @@ object Logic { checkAcyclic(clauses) problem.toLeft( - reduce0(clauses, initialFacts, Matched.empty) - ) + reduce0(clauses, initialFacts, Matched.empty)) } /** diff --git a/internal/util-logic/src/test/scala/sbt/logic/Test.scala b/internal/util-logic/src/test/scala/sbt/logic/Test.scala index f62a9e767..da1f0b706 100644 --- a/internal/util-logic/src/test/scala/sbt/logic/Test.scala +++ b/internal/util-logic/src/test/scala/sbt/logic/Test.scala @@ -20,8 +20,7 @@ object LogicTest extends Properties("Logic") { case Right(res) => false case Left(err: Logic.CyclicNegation) => true case Left(err) => sys.error(s"Expected cyclic error, got: $err") - } - ) + }) def expect(result: Either[LogicException, Matched], expected: Set[Atom]) = result match { case Left(err) => false diff --git a/project/p.sbt b/project/p.sbt new file mode 100644 index 000000000..eefc29672 --- /dev/null +++ b/project/p.sbt @@ -0,0 +1 @@ +addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.1.0") From 6175d9233848b220ad8b68f63c90e9b844903f0d Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Mon, 31 Aug 2015 15:25:10 +0200 Subject: [PATCH 2/2] Add recommended compiler flags, fix most of the warnings --- build.sbt | 38 +++++++++---------- .../main/scala/sbt/appmacro/ContextUtil.scala | 10 +++-- .../scala/sbt/appmacro/KListBuilder.scala | 2 +- .../scala/sbt/appmacro/TupleNBuilder.scala | 2 +- .../util-cache/src/main/scala/sbt/Cache.scala | 3 +- .../util-cache/src/test/scala/CacheTest.scala | 1 + .../src/main/scala/sbt/Dag.scala | 1 + .../src/main/scala/sbt/IDSet.scala | 2 +- .../src/main/scala/sbt/INode.scala | 3 +- .../src/main/scala/sbt/PMap.scala | 2 +- .../src/main/scala/sbt/Settings.scala | 10 ++--- .../src/main/scala/sbt/Signal.scala | 5 ++- .../src/main/scala/sbt/LineReader.scala | 3 +- .../src/main/scala/sbt/complete/History.scala | 11 +++--- .../scala/sbt/complete/HistoryCommands.scala | 2 +- .../scala/sbt/complete/JLineCompletion.scala | 2 +- .../src/main/scala/sbt/complete/Parser.scala | 8 ++-- .../src/main/scala/sbt/complete/Parsers.scala | 4 +- .../scala/sbt/complete/ProcessError.scala | 4 +- .../scala/sbt/complete/TokenCompletions.scala | 6 +-- .../main/scala/sbt/complete/UpperBound.scala | 4 +- .../src/test/scala/ParserTest.scala | 8 ++-- .../src/main/scala/sbt/BufferedLogger.scala | 7 +++- .../src/main/scala/sbt/ConsoleLogger.scala | 8 ++-- .../src/main/scala/sbt/ConsoleOut.scala | 2 +- .../src/main/scala/sbt/LoggerWriter.scala | 3 +- .../src/main/scala/sbt/StackTrace.scala | 3 +- .../src/test/scala/LogWriterTest.scala | 3 +- .../src/test/scala/sbt/logic/Test.scala | 5 ++- .../src/main/scala/sbt/ChangeReport.scala | 2 +- project/Dependencies.scala | 2 - 31 files changed, 92 insertions(+), 74 deletions(-) diff --git a/build.sbt b/build.sbt index cf41630d1..7f9a30bf1 100644 --- a/build.sbt +++ b/build.sbt @@ -25,8 +25,22 @@ def commonSettings: Seq[Setting[_]] = Seq( // concurrentRestrictions in Global += Util.testExclusiveRestriction, testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"), javacOptions in compile ++= Seq("-target", "6", "-source", "6", "-Xlint", "-Xlint:-serial"), - incOptions := incOptions.value.withNameHashing(true), - crossScalaVersions := Seq(scala210, scala211) + crossScalaVersions := Seq(scala210, scala211), + scalacOptions ++= Seq( + "-encoding", "utf8", + "-deprecation", + "-feature", + "-unchecked", + "-Xlint", + "-language:higherKinds", + "-language:implicitConversions", + // "-Xfuture", + "-Yinline-warnings", + // "-Yfatal-warnings", + "-Yno-adapted-args", + "-Ywarn-dead-code", + "-Ywarn-numeric-widen", + "-Ywarn-value-discard") // bintrayPackage := (bintrayPackage in ThisBuild).value, // bintrayRepository := (bintrayRepository in ThisBuild).value ) @@ -56,33 +70,20 @@ lazy val utilInterface = (project in internalPath / "util-interface"). commonSettings, javaOnlySettings, name := "Util Interface", - // projectComponent, exportJars := true - // resourceGenerators in Compile <+= (version, resourceManaged, streams, compile in Compile) map generateVersionFile, - // apiDefinitions <<= baseDirectory map { base => (base / "definition") :: (base / "other") :: (base / "type") :: Nil }, - // sourceGenerators in Compile <+= (apiDefinitions, - // fullClasspath in Compile in datatypeProj, - // sourceManaged in Compile, - // mainClass in datatypeProj in Compile, - // runner, - // streams) map generateAPICached ) lazy val utilControl = (project in internalPath / "util-control"). settings( commonSettings, - // Util.crossBuild, - name := "Util Control", - crossScalaVersions := Seq(scala210, scala211) + name := "Util Control" ) lazy val utilCollection = (project in internalPath / "util-collection"). settings( testedBaseSettings, Util.keywordsSettings, - // Util.crossBuild, - name := "Util Collection", - crossScalaVersions := Seq(scala210, scala211) + name := "Util Collection" ) lazy val utilApplyMacro = (project in internalPath / "util-appmacro"). @@ -98,7 +99,6 @@ lazy val utilComplete = (project in internalPath / "util-complete"). dependsOn(utilCollection, utilControl). settings( testedBaseSettings, - // Util.crossBuild, name := "Util Completion", libraryDependencies ++= Seq(jline, sbtIO), crossScalaVersions := Seq(scala210, scala211) @@ -144,5 +144,5 @@ lazy val utilTracking = (project in internalPath / "util-tracking"). settings( commonSettings, name := "Util Tracking", - libraryDependencies ++= Seq(sbtIO) + libraryDependencies += sbtIO ) diff --git a/internal/util-appmacro/src/main/scala/sbt/appmacro/ContextUtil.scala b/internal/util-appmacro/src/main/scala/sbt/appmacro/ContextUtil.scala index a2f1e4e47..1db77f24d 100644 --- a/internal/util-appmacro/src/main/scala/sbt/appmacro/ContextUtil.scala +++ b/internal/util-appmacro/src/main/scala/sbt/appmacro/ContextUtil.scala @@ -36,7 +36,7 @@ object ContextUtil { } // TODO 2.11 Remove this after dropping 2.10.x support. -private object HasCompat { val compat = ??? }; import HasCompat._ +private object HasCompat { val compat = this }; import HasCompat._ /** * Utility methods for macros. Several methods assume that the context's universe is a full compiler (`scala.tools.nsc.Global`). @@ -134,10 +134,14 @@ final class ContextUtil[C <: Context](val ctx: C) { def mkTuple(args: List[Tree]): Tree = global.gen.mkTuple(args.asInstanceOf[List[global.Tree]]).asInstanceOf[ctx.universe.Tree] - def setSymbol[Tree](t: Tree, sym: Symbol): Unit = + def setSymbol[Tree](t: Tree, sym: Symbol): Unit = { t.asInstanceOf[global.Tree].setSymbol(sym.asInstanceOf[global.Symbol]) - def setInfo[Tree](sym: Symbol, tpe: Type): Unit = + () + } + def setInfo[Tree](sym: Symbol, tpe: Type): Unit = { sym.asInstanceOf[global.Symbol].setInfo(tpe.asInstanceOf[global.Type]) + () + } /** Creates a new, synthetic type variable with the specified `owner`. */ def newTypeVariable(owner: Symbol, prefix: String = "T0"): TypeSymbol = diff --git a/internal/util-appmacro/src/main/scala/sbt/appmacro/KListBuilder.scala b/internal/util-appmacro/src/main/scala/sbt/appmacro/KListBuilder.scala index b5c2878f3..147f622bf 100644 --- a/internal/util-appmacro/src/main/scala/sbt/appmacro/KListBuilder.scala +++ b/internal/util-appmacro/src/main/scala/sbt/appmacro/KListBuilder.scala @@ -9,7 +9,7 @@ import macros._ /** A `TupleBuilder` that uses a KList as the tuple representation.*/ object KListBuilder extends TupleBuilder { // TODO 2.11 Remove this after dropping 2.10.x support. - private object HasCompat { val compat = ??? }; import HasCompat._ + private object HasCompat { val compat = this }; import HasCompat._ def make(c: Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type] { val ctx: c.type = c diff --git a/internal/util-appmacro/src/main/scala/sbt/appmacro/TupleNBuilder.scala b/internal/util-appmacro/src/main/scala/sbt/appmacro/TupleNBuilder.scala index 232174c81..ddef0bee3 100644 --- a/internal/util-appmacro/src/main/scala/sbt/appmacro/TupleNBuilder.scala +++ b/internal/util-appmacro/src/main/scala/sbt/appmacro/TupleNBuilder.scala @@ -16,7 +16,7 @@ object TupleNBuilder extends TupleBuilder { final val TupleMethodName = "tuple" // TODO 2.11 Remove this after dropping 2.10.x support. - private object HasCompat { val compat = ??? }; import HasCompat._ + private object HasCompat { val compat = this }; import HasCompat._ def make(c: Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type] { val util = ContextUtil[c.type](c) diff --git a/internal/util-cache/src/main/scala/sbt/Cache.scala b/internal/util-cache/src/main/scala/sbt/Cache.scala index bdfd8cb51..2547ddb4a 100644 --- a/internal/util-cache/src/main/scala/sbt/Cache.scala +++ b/internal/util-cache/src/main/scala/sbt/Cache.scala @@ -9,6 +9,7 @@ import java.net.{ URI, URL } import Types.:+: import DefaultProtocol.{ asProduct2, asSingleton, BooleanFormat, ByteFormat, IntFormat, wrap } import scala.xml.NodeSeq +import scala.language.existentials trait Cache[I, O] { def apply(file: File)(i: I): Either[O, O => Unit] @@ -200,7 +201,7 @@ trait UnionImplicits { def convert(in: UB) = uc.find(in) def read(in: Input) = { - val index = ByteFormat.reads(in) + val index = ByteFormat.reads(in).toInt val (cache, clazz) = uc.at(index) val value = cache.read(in) new Found[cache.Internal](cache, clazz, value, index) diff --git a/internal/util-cache/src/test/scala/CacheTest.scala b/internal/util-cache/src/test/scala/CacheTest.scala index ca66ba925..9208666d5 100644 --- a/internal/util-cache/src/test/scala/CacheTest.scala +++ b/internal/util-cache/src/test/scala/CacheTest.scala @@ -27,5 +27,6 @@ object CacheTest // extends Properties("Cache test") (len + 1) :+: file :+: HNil } c(create :+: fileLength :+: HNil) + () } } diff --git a/internal/util-collection/src/main/scala/sbt/Dag.scala b/internal/util-collection/src/main/scala/sbt/Dag.scala index 118cd0dff..3eb3d8ccb 100644 --- a/internal/util-collection/src/main/scala/sbt/Dag.scala +++ b/internal/util-collection/src/main/scala/sbt/Dag.scala @@ -26,6 +26,7 @@ object Dag { discovered(node) = true; try { visitAll(dependencies(node)); } catch { case c: Cyclic => throw node :: c } finished += node + () } else if (!finished(node)) throw new Cyclic(node) } diff --git a/internal/util-collection/src/main/scala/sbt/IDSet.scala b/internal/util-collection/src/main/scala/sbt/IDSet.scala index 4f5245a26..7c21c48a7 100644 --- a/internal/util-collection/src/main/scala/sbt/IDSet.scala +++ b/internal/util-collection/src/main/scala/sbt/IDSet.scala @@ -33,7 +33,7 @@ object IDSet { def apply(t: T) = contains(t) def contains(t: T) = backing.containsKey(t) def foreach(f: T => Unit) = all foreach f - def +=(t: T) = backing.put(t, Dummy) + def +=(t: T) = { backing.put(t, Dummy); () } def ++=(t: Iterable[T]) = t foreach += def -=(t: T) = if (backing.remove(t) eq null) false else true def all = collection.JavaConversions.collectionAsScalaIterable(backing.keySet) diff --git a/internal/util-collection/src/main/scala/sbt/INode.scala b/internal/util-collection/src/main/scala/sbt/INode.scala index ce39fadad..e55ee9683 100644 --- a/internal/util-collection/src/main/scala/sbt/INode.scala +++ b/internal/util-collection/src/main/scala/sbt/INode.scala @@ -79,7 +79,7 @@ abstract class EvaluateSettings[Scope] { workComplete() } - private[this] def startWork(): Unit = running.incrementAndGet() + private[this] def startWork(): Unit = { running.incrementAndGet(); () } private[this] def workComplete(): Unit = if (running.decrementAndGet() == 0) complete.put(None) @@ -154,6 +154,7 @@ abstract class EvaluateSettings[Scope] { case Evaluated => submitCallComplete(by, value) case _ => calledBy += by } + () } protected def dependsOn: Seq[INode[_]] protected def evaluate0(): Unit diff --git a/internal/util-collection/src/main/scala/sbt/PMap.scala b/internal/util-collection/src/main/scala/sbt/PMap.scala index cf0454fd9..979e776fa 100644 --- a/internal/util-collection/src/main/scala/sbt/PMap.scala +++ b/internal/util-collection/src/main/scala/sbt/PMap.scala @@ -15,7 +15,7 @@ trait RMap[K[_], V[_]] { def values: Iterable[V[_]] def isEmpty: Boolean - final case class TPair[T](key: K[T], value: V[T]) + sealed case class TPair[T](key: K[T], value: V[T]) } trait IMap[K[_], V[_]] extends (K ~> V) with RMap[K, V] { diff --git a/internal/util-collection/src/main/scala/sbt/Settings.scala b/internal/util-collection/src/main/scala/sbt/Settings.scala index eb4227d09..018d5dfc0 100644 --- a/internal/util-collection/src/main/scala/sbt/Settings.scala +++ b/internal/util-collection/src/main/scala/sbt/Settings.scala @@ -19,7 +19,7 @@ sealed trait Settings[Scope] { private final class Settings0[Scope](val data: Map[Scope, AttributeMap], val delegates: Scope => Seq[Scope]) extends Settings[Scope] { def scopes: Set[Scope] = data.keySet def keys(scope: Scope) = data(scope).keys.toSet - def allKeys[T](f: (Scope, AttributeKey[_]) => T): Seq[T] = data.flatMap { case (scope, map) => map.keys.map(k => f(scope, k)) } toSeq + def allKeys[T](f: (Scope, AttributeKey[_]) => T): Seq[T] = data.flatMap { case (scope, map) => map.keys.map(k => f(scope, k)) }.toSeq def get[T](scope: Scope, key: AttributeKey[T]): Option[T] = delegates(scope).toStream.flatMap(sc => getDirect(sc, key)).headOption @@ -42,7 +42,7 @@ trait Init[Scope] { /** The Show instance used when a detailed String needs to be generated. It is typically used when no context is available.*/ def showFullKey: Show[ScopedKey[_]] - final case class ScopedKey[T](scope: Scope, key: AttributeKey[T]) extends KeyedInitialize[T] { + sealed case class ScopedKey[T](scope: Scope, key: AttributeKey[T]) extends KeyedInitialize[T] { def scopedKey = this } @@ -154,9 +154,9 @@ trait Init[Scope] { def compile(sMap: ScopedMap): CompiledMap = sMap.toTypedSeq.map { case sMap.TPair(k, ss) => - val deps = ss flatMap { _.dependencies } toSet; + val deps = ss.flatMap(_.dependencies).toSet (k, new Compiled(k, deps, ss)) - } toMap; + }.toMap def grouped(init: Seq[Setting[_]]): ScopedMap = ((IMap.empty: ScopedMap) /: init)((m, s) => add(m, s)) @@ -445,7 +445,7 @@ trait Init[Scope] { def join: Initialize[Seq[T]] = uniform(s)(idFun) } def join[T](inits: Seq[Initialize[T]]): Initialize[Seq[T]] = uniform(inits)(idFun) - def joinAny[M[_]](inits: Seq[Initialize[M[T]] forSome { type T }]): Initialize[Seq[M[_]]] = + def joinAny[M[_], T](inits: Seq[Initialize[M[T]]]): Initialize[Seq[M[_]]] = join(inits.asInstanceOf[Seq[Initialize[M[Any]]]]).asInstanceOf[Initialize[Seq[M[T] forSome { type T }]]] } object SettingsDefinition { diff --git a/internal/util-collection/src/main/scala/sbt/Signal.scala b/internal/util-collection/src/main/scala/sbt/Signal.scala index e8c9e7e6c..5aa5fc86e 100644 --- a/internal/util-collection/src/main/scala/sbt/Signal.scala +++ b/internal/util-collection/src/main/scala/sbt/Signal.scala @@ -37,6 +37,7 @@ object Signals { object unregisterNewHandler extends Registration { override def remove(): Unit = { Signal.handle(intSignal, oldHandler) + () } } unregisterNewHandler @@ -80,6 +81,6 @@ private final class Signals0 { try Right(action()) catch { case e: LinkageError => Left(e) } - finally Signal.handle(intSignal, oldHandler) + finally { Signal.handle(intSignal, oldHandler); () } } -} \ No newline at end of file +} diff --git a/internal/util-complete/src/main/scala/sbt/LineReader.scala b/internal/util-complete/src/main/scala/sbt/LineReader.scala index b85190f92..41679ab6e 100644 --- a/internal/util-complete/src/main/scala/sbt/LineReader.scala +++ b/internal/util-complete/src/main/scala/sbt/LineReader.scala @@ -65,7 +65,7 @@ private object JLine { // translate explicit class names to type in order to support // older Scala, since it shaded classes but not the system property - private[sbt] def fixTerminalProperty() { + private[sbt] def fixTerminalProperty(): Unit = { val newValue = System.getProperty(TerminalProperty) match { case "jline.UnixTerminal" => "unix" case null if System.getProperty("sbt.cygwin") != null => "unix" @@ -75,6 +75,7 @@ private object JLine { case x => x } if (newValue != null) System.setProperty(TerminalProperty, newValue) + () } // When calling this, ensure that enableEcho has been or will be called. diff --git a/internal/util-complete/src/main/scala/sbt/complete/History.scala b/internal/util-complete/src/main/scala/sbt/complete/History.scala index 26d0a27c6..614244b9e 100644 --- a/internal/util-complete/src/main/scala/sbt/complete/History.scala +++ b/internal/util-complete/src/main/scala/sbt/complete/History.scala @@ -13,7 +13,7 @@ final class History private (val lines: IndexedSeq[String], val path: Option[Fil def all: Seq[String] = lines def size = lines.length def !! : Option[String] = !-(1) - def apply(i: Int): Option[String] = if (0 <= i && i < size) Some(lines(i)) else { sys.error("Invalid history index: " + i); None } + def apply(i: Int): Option[String] = if (0 <= i && i < size) Some(lines(i)) else { sys.error("Invalid history index: " + i) } def !(i: Int): Option[String] = apply(i) def !(s: String): Option[String] = @@ -26,14 +26,13 @@ final class History private (val lines: IndexedSeq[String], val path: Option[Fil def !?(s: String): Option[String] = nonEmpty(s) { reversed.drop(1).find(_.contains(s)) } private def nonEmpty[T](s: String)(act: => Option[T]): Option[T] = - if (s.isEmpty) { + if (s.isEmpty) sys.error("No action specified to history command") - None - } else + else act def list(historySize: Int, show: Int): Seq[String] = - lines.toList.drop((lines.size - historySize) max 0).zipWithIndex.map { case (line, number) => " " + number + " " + line }.takeRight(show max 1) + lines.toList.drop(scala.math.max(0, lines.size - historySize)).zipWithIndex.map { case (line, number) => " " + number + " " + line }.takeRight(show max 1) } object History { @@ -42,4 +41,4 @@ object History { def number(s: String): Option[Int] = try { Some(s.toInt) } catch { case e: NumberFormatException => None } -} \ No newline at end of file +} diff --git a/internal/util-complete/src/main/scala/sbt/complete/HistoryCommands.scala b/internal/util-complete/src/main/scala/sbt/complete/HistoryCommands.scala index ff58fe9d2..b66d3272e 100644 --- a/internal/util-complete/src/main/scala/sbt/complete/HistoryCommands.scala +++ b/internal/util-complete/src/main/scala/sbt/complete/HistoryCommands.scala @@ -45,7 +45,7 @@ object HistoryCommands { val MaxLines = 500 lazy val num = token(NatBasic, "") - lazy val last = Last ^^^ { execute(_ !!) } + lazy val last = Last ^^^ { execute(_.!!) } lazy val list = ListCommands ~> (num ?? Int.MaxValue) map { show => (h: History) => { printHistory(h, MaxLines, show); Some(Nil) } } diff --git a/internal/util-complete/src/main/scala/sbt/complete/JLineCompletion.scala b/internal/util-complete/src/main/scala/sbt/complete/JLineCompletion.scala index fed89541f..2445fd111 100644 --- a/internal/util-complete/src/main/scala/sbt/complete/JLineCompletion.scala +++ b/internal/util-complete/src/main/scala/sbt/complete/JLineCompletion.scala @@ -149,7 +149,7 @@ object JLineCompletion { def commonPrefix(s: Seq[String]): String = if (s.isEmpty) "" else s reduceLeft commonPrefix def commonPrefix(a: String, b: String): String = { - val len = a.length min b.length + val len = scala.math.min(a.length, b.length) @tailrec def loop(i: Int): Int = if (i >= len) len else if (a(i) != b(i)) i else loop(i + 1) a.substring(0, loop(0)) } diff --git a/internal/util-complete/src/main/scala/sbt/complete/Parser.scala b/internal/util-complete/src/main/scala/sbt/complete/Parser.scala index 892119f6c..7ae7ea0fd 100644 --- a/internal/util-complete/src/main/scala/sbt/complete/Parser.scala +++ b/internal/util-complete/src/main/scala/sbt/complete/Parser.scala @@ -300,9 +300,9 @@ trait ParserMain { def !!!(msg: String): Parser[A] = onFailure(a, msg) def failOnException: Parser[A] = trapAndFail(a) - def unary_- = not(a) + def unary_- = not(a, "Unexpected: " + a) def &(o: Parser[_]) = and(a, o) - def -(o: Parser[_]) = sub(a, o) + def -(o: Parser[_]) = and(a, not(o, "Unexpected: " + o)) def examples(s: String*): Parser[A] = examples(s.toSet) def examples(s: Set[String], check: Boolean = false): Parser[A] = examples(new FixedSetExamples(s), s.size, check) def examples(s: ExampleSource, maxNumberOfExamples: Int, removeInvalidExamples: Boolean): Parser[A] = Parser.examples(a, s, maxNumberOfExamples, removeInvalidExamples) @@ -366,7 +366,7 @@ trait ParserMain { def result = None def resultEmpty = mkFailure("Expected '" + ch + "'") def derive(c: Char) = if (c == ch) success(ch) else new Invalid(resultEmpty) - def completions(level: Int) = Completions.single(Completion.suggestStrict(ch.toString)) + def completions(level: Int) = Completions.single(Completion.suggestion(ch.toString)) override def toString = "'" + ch + "'" } /** Presents a literal String `s` as a Parser that only parses that exact text and provides it as the result.*/ @@ -812,7 +812,7 @@ private final class Repeat[T](partial: Option[Parser[T]], repeated: Parser[T], m case None => repeatDerive(c, accumulatedReverse) } - def repeatDerive(c: Char, accRev: List[T]): Parser[Seq[T]] = repeat(Some(repeated derive c), repeated, (min - 1) max 0, max.decrement, accRev) + def repeatDerive(c: Char, accRev: List[T]): Parser[Seq[T]] = repeat(Some(repeated derive c), repeated, scala.math.max(0, min - 1), max.decrement, accRev) def completions(level: Int) = { diff --git a/internal/util-complete/src/main/scala/sbt/complete/Parsers.scala b/internal/util-complete/src/main/scala/sbt/complete/Parsers.scala index 3183929e8..af5849870 100644 --- a/internal/util-complete/src/main/scala/sbt/complete/Parsers.scala +++ b/internal/util-complete/src/main/scala/sbt/complete/Parsers.scala @@ -11,7 +11,7 @@ import java.lang.Character.{ getType, MATH_SYMBOL, OTHER_SYMBOL, DASH_PUNCTUATIO /** Provides standard implementations of commonly useful [[Parser]]s. */ trait Parsers { /** Matches the end of input, providing no useful result on success. */ - lazy val EOF = not(any) + lazy val EOF = not(any, "Expected EOF") /** Parses any single character and provides that character as the result. */ lazy val any: Parser[Char] = charClass(_ => true, "any character") @@ -265,4 +265,4 @@ object DefaultParsers extends Parsers with ParserMain { /** Returns `true` if `s` parses successfully according to [[ID]].*/ def validID(s: String): Boolean = matches(ID, s) -} \ No newline at end of file +} diff --git a/internal/util-complete/src/main/scala/sbt/complete/ProcessError.scala b/internal/util-complete/src/main/scala/sbt/complete/ProcessError.scala index 7e6c9794e..d85e523c9 100644 --- a/internal/util-complete/src/main/scala/sbt/complete/ProcessError.scala +++ b/internal/util-complete/src/main/scala/sbt/complete/ProcessError.scala @@ -25,5 +25,5 @@ object ProcessError { s.substring(i + 1) loop(s.length - 1) } - def pointerSpace(s: String, i: Int): String = (s take i) map { case '\t' => '\t'; case _ => ' ' } mkString; -} \ No newline at end of file + def pointerSpace(s: String, i: Int): String = (s take i) map { case '\t' => '\t'; case _ => ' ' } mkString "" +} diff --git a/internal/util-complete/src/main/scala/sbt/complete/TokenCompletions.scala b/internal/util-complete/src/main/scala/sbt/complete/TokenCompletions.scala index 96e70d2f1..1285507cc 100644 --- a/internal/util-complete/src/main/scala/sbt/complete/TokenCompletions.scala +++ b/internal/util-complete/src/main/scala/sbt/complete/TokenCompletions.scala @@ -1,6 +1,6 @@ package sbt.complete -import Completion.{ displayStrict, token => ctoken, tokenDisplay } +import Completion.{ token => ctoken, tokenDisplay } sealed trait TokenCompletions { def hideWhen(f: Int => Boolean): TokenCompletions @@ -24,7 +24,7 @@ object TokenCompletions { val default: TokenCompletions = mapDelegateCompletions((seen, level, c) => ctoken(seen, c.append)) def displayOnly(msg: String): TokenCompletions = new Fixed { - def completions(seen: String, level: Int) = Completions.single(displayStrict(msg)) + def completions(seen: String, level: Int) = Completions.single(Completion.displayOnly(msg)) } def overrideDisplay(msg: String): TokenCompletions = mapDelegateCompletions((seen, level, c) => tokenDisplay(display = msg, append = c.append)) @@ -34,4 +34,4 @@ object TokenCompletions { def mapDelegateCompletions(f: (String, Int, Completion) => Completion): TokenCompletions = new Delegating { def completions(seen: String, level: Int, delegate: Completions) = Completions(delegate.get.map(c => f(seen, level, c))) } -} \ No newline at end of file +} diff --git a/internal/util-complete/src/main/scala/sbt/complete/UpperBound.scala b/internal/util-complete/src/main/scala/sbt/complete/UpperBound.scala index 66a32e1a2..2d954d4c5 100644 --- a/internal/util-complete/src/main/scala/sbt/complete/UpperBound.scala +++ b/internal/util-complete/src/main/scala/sbt/complete/UpperBound.scala @@ -38,10 +38,10 @@ final case class Finite(value: Int) extends UpperBound { def >=(min: Int) = value >= min def isOne = value == 1 def isZero = value == 0 - def decrement = Finite((value - 1) max 0) + def decrement = Finite(scala.math.max(0, value - 1)) def isInfinite = false override def toString = value.toString } object UpperBound { implicit def intToFinite(i: Int): Finite = Finite(i) -} \ No newline at end of file +} diff --git a/internal/util-complete/src/test/scala/ParserTest.scala b/internal/util-complete/src/test/scala/ParserTest.scala index f02431e53..c70c6207b 100644 --- a/internal/util-complete/src/test/scala/ParserTest.scala +++ b/internal/util-complete/src/test/scala/ParserTest.scala @@ -109,13 +109,13 @@ object ParserTest extends Properties("Completing Parser") { property("repeatDep accepts two tokens") = matches(repeat, colors.toSeq.take(2).mkString(" ")) } object ParserExample { - val ws = charClass(_.isWhitespace)+ - val notws = charClass(!_.isWhitespace)+ + val ws = charClass(_.isWhitespace).+ + val notws = charClass(!_.isWhitespace).+ val name = token("test") - val options = (ws ~> token("quick" | "failed" | "new"))* + val options = (ws ~> token("quick" | "failed" | "new")).* val exampleSet = Set("am", "is", "are", "was", "were") - val include = (ws ~> token(examples(notws.string, new FixedSetExamples(exampleSet), exampleSet.size, false)))* + val include = (ws ~> token(examples(notws.string, new FixedSetExamples(exampleSet), exampleSet.size, false))).* val t = name ~ options ~ include diff --git a/internal/util-logging/src/main/scala/sbt/BufferedLogger.scala b/internal/util-logging/src/main/scala/sbt/BufferedLogger.scala index 08a60577d..488de77bb 100644 --- a/internal/util-logging/src/main/scala/sbt/BufferedLogger.scala +++ b/internal/util-logging/src/main/scala/sbt/BufferedLogger.scala @@ -52,6 +52,7 @@ class BufferedLogger(delegate: AbstractLogger) extends BasicLogger { buffer += new SetLevel(newLevel) else delegate.setLevel(newLevel) + () } override def setSuccessEnabled(flag: Boolean): Unit = synchronized { super.setSuccessEnabled(flag) @@ -59,6 +60,7 @@ class BufferedLogger(delegate: AbstractLogger) extends BasicLogger { buffer += new SetSuccess(flag) else delegate.setSuccessEnabled(flag) + () } override def setTrace(level: Int): Unit = synchronized { super.setTrace(level) @@ -66,6 +68,7 @@ class BufferedLogger(delegate: AbstractLogger) extends BasicLogger { buffer += new SetTrace(level) else delegate.setTrace(level) + () } def trace(t: => Throwable): Unit = @@ -79,6 +82,7 @@ class BufferedLogger(delegate: AbstractLogger) extends BasicLogger { buffer ++= events else delegate.logAll(events) + () } def control(event: ControlEvent.Value, message: => String): Unit = doBufferable(Level.Info, new ControlEvent(event, message), _.control(event, message)) @@ -91,5 +95,6 @@ class BufferedLogger(delegate: AbstractLogger) extends BasicLogger { else doUnbuffered(delegate) } + () } -} \ No newline at end of file +} diff --git a/internal/util-logging/src/main/scala/sbt/ConsoleLogger.scala b/internal/util-logging/src/main/scala/sbt/ConsoleLogger.scala index c1558cc66..7ecb7d186 100644 --- a/internal/util-logging/src/main/scala/sbt/ConsoleLogger.scala +++ b/internal/util-logging/src/main/scala/sbt/ConsoleLogger.scala @@ -34,8 +34,7 @@ object ConsoleLogger { * * cf. http://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes */ - @deprecated("No longer public.", "0.13.8") - def isEscapeTerminator(c: Char): Boolean = + private[sbt] def isEscapeTerminator(c: Char): Boolean = c >= '@' && c <= '~' /** @@ -83,9 +82,10 @@ object ConsoleLogger { } private[this] def nextESC(s: String, start: Int, sb: java.lang.StringBuilder): Unit = { val escIndex = s.indexOf(ESC, start) - if (escIndex < 0) + if (escIndex < 0) { sb.append(s, start, s.length) - else { + () + } else { sb.append(s, start, escIndex) val next: Int = // If it's a CSI we skip past it and then look for a terminator. diff --git a/internal/util-logging/src/main/scala/sbt/ConsoleOut.scala b/internal/util-logging/src/main/scala/sbt/ConsoleOut.scala index 3ce0d8cdf..3d2c15abe 100644 --- a/internal/util-logging/src/main/scala/sbt/ConsoleOut.scala +++ b/internal/util-logging/src/main/scala/sbt/ConsoleOut.scala @@ -29,7 +29,7 @@ object ConsoleOut { val lockObject = System.out private[this] var last: Option[String] = None private[this] var current = new java.lang.StringBuffer - def print(s: String): Unit = synchronized { current.append(s) } + def print(s: String): Unit = synchronized { current.append(s); () } def println(s: String): Unit = synchronized { current.append(s); println() } def println(): Unit = synchronized { val s = current.toString diff --git a/internal/util-logging/src/main/scala/sbt/LoggerWriter.scala b/internal/util-logging/src/main/scala/sbt/LoggerWriter.scala index 9be8af409..a106ff605 100644 --- a/internal/util-logging/src/main/scala/sbt/LoggerWriter.scala +++ b/internal/util-logging/src/main/scala/sbt/LoggerWriter.scala @@ -43,7 +43,8 @@ class LoggerWriter(delegate: Logger, unbufferedLevel: Option[Level.Value], nl: S } } private[this] def log(s: String): Unit = unbufferedLevel match { - case None => lines += s + case None => + lines += s; () case Some(level) => delegate.log(level, s) } } diff --git a/internal/util-logging/src/main/scala/sbt/StackTrace.scala b/internal/util-logging/src/main/scala/sbt/StackTrace.scala index 70554c5ec..d6504cb10 100644 --- a/internal/util-logging/src/main/scala/sbt/StackTrace.scala +++ b/internal/util-logging/src/main/scala/sbt/StackTrace.scala @@ -34,6 +34,7 @@ object StackTrace { b.append("\tat ") b.append(e) b.append('\n') + () } if (!first) @@ -59,4 +60,4 @@ object StackTrace { b.toString() } -} \ No newline at end of file +} diff --git a/internal/util-logging/src/test/scala/LogWriterTest.scala b/internal/util-logging/src/test/scala/LogWriterTest.scala index ce96e9bc9..7c0125fba 100644 --- a/internal/util-logging/src/test/scala/LogWriterTest.scala +++ b/internal/util-logging/src/test/scala/LogWriterTest.scala @@ -120,7 +120,8 @@ object Escape { { val builder = new StringBuilder(s.length) for (c <- s) { - def escaped = pad(c.toInt.toHexString.toUpperCase, 4, '0') + val char = c.toInt + def escaped = pad(char.toHexString.toUpperCase, 4, '0') if (c < 20) builder.append("\\u").append(escaped) else builder.append(c) } builder.toString diff --git a/internal/util-logic/src/test/scala/sbt/logic/Test.scala b/internal/util-logic/src/test/scala/sbt/logic/Test.scala index da1f0b706..f9957414b 100644 --- a/internal/util-logic/src/test/scala/sbt/logic/Test.scala +++ b/internal/util-logic/src/test/scala/sbt/logic/Test.scala @@ -26,7 +26,10 @@ object LogicTest extends Properties("Logic") { case Left(err) => false case Right(res) => val actual = res.provenSet - (actual == expected) || sys.error(s"Expected to prove $expected, but actually proved $actual") + if (actual != expected) + sys.error(s"Expected to prove $expected, but actually proved $actual") + else + true } } diff --git a/internal/util-tracking/src/main/scala/sbt/ChangeReport.scala b/internal/util-tracking/src/main/scala/sbt/ChangeReport.scala index 8502f9d3f..25e3ca0ff 100644 --- a/internal/util-tracking/src/main/scala/sbt/ChangeReport.scala +++ b/internal/util-tracking/src/main/scala/sbt/ChangeReport.scala @@ -67,4 +67,4 @@ private class CompoundChangeReport[T](a: ChangeReport[T], b: ChangeReport[T]) ex lazy val modified = a.modified ++ b.modified lazy val added = a.added ++ b.added lazy val removed = a.removed ++ b.removed -} \ No newline at end of file +} diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 0313a7267..7da889422 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -5,8 +5,6 @@ object Dependencies { lazy val scala210 = "2.10.5" lazy val scala211 = "2.11.7" - val bootstrapSbtVersion = "0.13.8" - lazy val sbtIO = "org.scala-sbt" %% "io" % "1.0.0-M1" lazy val jline = "jline" % "jline" % "2.11" lazy val sbtSerialization = "org.scala-sbt" %% "serialization" % "0.1.2"