From 3b111fa1ebfdd4d9fa35ba00c7e1c61a291ef9de Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Tue, 2 May 2017 22:15:40 +0200 Subject: [PATCH] Fix compilation warnings --- cache/src/main/scala/coursier/TermDisplay.scala | 2 +- cli/src/main/scala-2.11/coursier/cli/Helper.scala | 14 +++++++------- .../coursier/cli/scaladex/Scaladex.scala | 1 + .../main/scala-2.10/coursier/ResolutionError.scala | 6 +++--- .../src/main/scala-2.10/coursier/Tasks.scala | 10 +++++----- .../scala/coursier/sbtlauncher/AppProvider.scala | 2 ++ .../main/scala/coursier/sbtlauncher/Launcher.scala | 1 + .../test/scala/coursier/test/ChecksumTests.scala | 2 +- .../coursier/test/compatibility/package.scala | 2 +- 9 files changed, 22 insertions(+), 18 deletions(-) diff --git a/cache/src/main/scala/coursier/TermDisplay.scala b/cache/src/main/scala/coursier/TermDisplay.scala index d1bc009fe..59e8abe88 100644 --- a/cache/src/main/scala/coursier/TermDisplay.scala +++ b/cache/src/main/scala/coursier/TermDisplay.scala @@ -455,7 +455,7 @@ class TermDisplay( /** * - * @return: whether any message was printed by this `TermDisplay` + * @return whether any message was printed by this `TermDisplay` */ def stopDidPrintSomething(): Boolean = { scheduler.shutdown() diff --git a/cli/src/main/scala-2.11/coursier/cli/Helper.scala b/cli/src/main/scala-2.11/coursier/cli/Helper.scala index 4cb4da49c..45b1cc2bb 100644 --- a/cli/src/main/scala-2.11/coursier/cli/Helper.scala +++ b/cli/src/main/scala-2.11/coursier/cli/Helper.scala @@ -163,6 +163,9 @@ class Helper( } + val loggerFallbackMode = + !progress && TermDisplay.defaultFallbackMode + val (scaladexRawDependencies, otherRawDependencies) = rawDependencies.partition(s => s.contains("/") || !s.contains(":")) @@ -364,9 +367,6 @@ class Helper( mapDependencies = if (typelevel) Some(Typelevel.swap(_)) else None ) - val loggerFallbackMode = - !progress && TermDisplay.defaultFallbackMode - val logger = if (verbosityLevel >= 0) Some(new TermDisplay( @@ -465,7 +465,7 @@ class Helper( iterationCounter, 0 ) - ).run + ).unsafePerformSync Console.err.println(s"Overhead: ${resolutionCounter.value - iterationCounter.value} ms") @@ -491,7 +491,7 @@ class Helper( val res0 = startRes .process .run(fetch0, maxIterations) - .run + .unsafePerformSync val end = System.currentTimeMillis() Console.err.println(s"Resolution ${index + 1} / ${-benchmark}: ${end - start} ms") @@ -515,7 +515,7 @@ class Helper( startRes .process .run(fetch0, maxIterations) - .run + .unsafePerformSync logger.foreach(_.stop()) @@ -674,7 +674,7 @@ class Helper( val task = Task.gatherUnordered(tasks) - val results = task.run + val results = task.unsafePerformSync val errors = results.collect{case (artifact, -\/(err)) => artifact -> err } val files0 = results.collect{case (artifact, \/-(f)) => f } diff --git a/cli/src/main/scala-2.11/coursier/cli/scaladex/Scaladex.scala b/cli/src/main/scala-2.11/coursier/cli/scaladex/Scaladex.scala index 618a24e2f..767415c57 100644 --- a/cli/src/main/scala-2.11/coursier/cli/scaladex/Scaladex.scala +++ b/cli/src/main/scala-2.11/coursier/cli/scaladex/Scaladex.scala @@ -8,6 +8,7 @@ import argonaut._, Argonaut._, ArgonautShapeless._ import coursier.core.{ Artifact, Attributes } import coursier.{ Fetch, Module } +import scala.language.higherKinds import scalaz.{ -\/, EitherT, Monad, Nondeterminism, \/, \/- } import scalaz.Scalaz.ToEitherOps import scalaz.Scalaz.ToEitherOpsFromEither diff --git a/sbt-coursier/src/main/scala-2.10/coursier/ResolutionError.scala b/sbt-coursier/src/main/scala-2.10/coursier/ResolutionError.scala index cc246c3d9..603163ed2 100644 --- a/sbt-coursier/src/main/scala-2.10/coursier/ResolutionError.scala +++ b/sbt-coursier/src/main/scala-2.10/coursier/ResolutionError.scala @@ -43,7 +43,7 @@ object ResolutionError { final case class UnknownDownloadException(ex: Throwable) extends ResolutionError final case class Conflicts(description: String) extends ResolutionError - final case class MetadataDownloadErrors(errors: Seq[(Dependency, Seq[String])]) extends ResolutionError { + final case class MetadataDownloadErrors(errors: Seq[((Module, String), Seq[String])]) extends ResolutionError { def description(): String = { def grouped(errs: Seq[String]) = @@ -64,8 +64,8 @@ object ResolutionError { lines += s"Encountered ${errors.length} error(s) in dependency resolution:" - for ((dep, errs) <- errors) { - lines += s" ${dep.module}:${dep.version}:" + for (((mod, ver), errs) <- errors) { + lines += s" $mod:$ver:" for ((type0, errs0) <- grouped(errs)) if (type0.isEmpty) diff --git a/sbt-coursier/src/main/scala-2.10/coursier/Tasks.scala b/sbt-coursier/src/main/scala-2.10/coursier/Tasks.scala index a7624c3bb..224bd7f66 100644 --- a/sbt-coursier/src/main/scala-2.10/coursier/Tasks.scala +++ b/sbt-coursier/src/main/scala-2.10/coursier/Tasks.scala @@ -677,7 +677,7 @@ object Tasks { startRes .process .run(fetch, maxIterations) - .attemptRun + .unsafePerformSyncAttempt .leftMap(ex => ResolutionError.UnknownException(ex) .throwException() @@ -704,17 +704,17 @@ object Tasks { ).throwException() } - if (res.errors.nonEmpty) { + if (res.metadataErrors.nonEmpty) { val internalRepositoriesLen = internalRepositories.length val errors = if (repositories.length > internalRepositoriesLen) // drop internal repository errors - res.errors.map { + res.metadataErrors.map { case (dep, errs) => dep -> errs.drop(internalRepositoriesLen) } else - res.errors + res.metadataErrors ResolutionError.MetadataDownloadErrors(errors) .throwException() @@ -823,7 +823,7 @@ object Tasks { artifactsLogger.init(if (printOptionalMessage) log.info(artifactInitialMessage)) - Task.gatherUnordered(artifactFileOrErrorTasks).attemptRun match { + Task.gatherUnordered(artifactFileOrErrorTasks).unsafePerformSyncAttempt match { case -\/(ex) => ResolutionError.UnknownDownloadException(ex) .throwException() diff --git a/sbt-launcher/src/main/scala/coursier/sbtlauncher/AppProvider.scala b/sbt-launcher/src/main/scala/coursier/sbtlauncher/AppProvider.scala index ac671f138..932652a50 100644 --- a/sbt-launcher/src/main/scala/coursier/sbtlauncher/AppProvider.scala +++ b/sbt-launcher/src/main/scala/coursier/sbtlauncher/AppProvider.scala @@ -2,6 +2,8 @@ package coursier.sbtlauncher import java.io.File +import scala.language.existentials + final case class AppProvider( scalaProvider: xsbti.ScalaProvider, id: xsbti.ApplicationID, diff --git a/sbt-launcher/src/main/scala/coursier/sbtlauncher/Launcher.scala b/sbt-launcher/src/main/scala/coursier/sbtlauncher/Launcher.scala index cf10cb315..b560a98a7 100644 --- a/sbt-launcher/src/main/scala/coursier/sbtlauncher/Launcher.scala +++ b/sbt-launcher/src/main/scala/coursier/sbtlauncher/Launcher.scala @@ -10,6 +10,7 @@ import coursier.ivy.IvyRepository import coursier.maven.MavenSource import scala.annotation.tailrec +import scala.language.reflectiveCalls import scalaz.{-\/, \/-} import scalaz.concurrent.Task diff --git a/tests/jvm/src/test/scala/coursier/test/ChecksumTests.scala b/tests/jvm/src/test/scala/coursier/test/ChecksumTests.scala index cbe20e8f4..729846a94 100644 --- a/tests/jvm/src/test/scala/coursier/test/ChecksumTests.scala +++ b/tests/jvm/src/test/scala/coursier/test/ChecksumTests.scala @@ -59,7 +59,7 @@ object ChecksumTests extends TestSuite { sumType, cache, Strategy.DefaultExecutorService - ).run.run + ).run.unsafePerformSync def artifact(url: String) = Artifact( url, diff --git a/tests/jvm/src/test/scala/coursier/test/compatibility/package.scala b/tests/jvm/src/test/scala/coursier/test/compatibility/package.scala index 808c739d4..45a344884 100644 --- a/tests/jvm/src/test/scala/coursier/test/compatibility/package.scala +++ b/tests/jvm/src/test/scala/coursier/test/compatibility/package.scala @@ -10,7 +10,7 @@ package object compatibility { implicit val executionContext = scala.concurrent.ExecutionContext.global implicit class TaskExtensions[T](val underlying: Task[T]) extends AnyVal { - def runF: Future[T] = Future.successful(underlying.run) + def runF: Future[T] = Future.successful(underlying.unsafePerformSync) } def textResource(path: String)(implicit ec: ExecutionContext): Future[String] = Future {