Remove all warnings from collectionProj

This commit is contained in:
Dale Wijnand 2017-12-04 15:50:45 +00:00
parent 1f1806a4f1
commit b80a6b217b
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
6 changed files with 21 additions and 13 deletions

View File

@ -157,6 +157,11 @@ val collectionProj = (project in file("internal") / "util-collection")
exclude[MissingClassProblem]("sbt.internal.util.Fn1"), exclude[MissingClassProblem]("sbt.internal.util.Fn1"),
exclude[DirectMissingMethodProblem]("sbt.internal.util.TypeFunctions.toFn1"), exclude[DirectMissingMethodProblem]("sbt.internal.util.TypeFunctions.toFn1"),
exclude[DirectMissingMethodProblem]("sbt.internal.util.Types.toFn1"), exclude[DirectMissingMethodProblem]("sbt.internal.util.Types.toFn1"),
// Instead of defining foldr in KList & overriding in KCons,
// it's now abstract in KList and defined in both KCons & KNil.
exclude[FinalMethodProblem]("sbt.internal.util.KNil.foldr"),
exclude[DirectAbstractMethodProblem]("sbt.internal.util.KList.foldr"),
), ),
) )
.configure(addSbtUtilPosition) .configure(addSbtUtilPosition)

View File

@ -7,6 +7,8 @@
package sbt.internal.util package sbt.internal.util
import scala.collection.JavaConverters._
/** A mutable set interface that uses object identity to test for set membership.*/ /** A mutable set interface that uses object identity to test for set membership.*/
trait IDSet[T] { trait IDSet[T] {
def apply(t: T): Boolean def apply(t: T): Boolean
@ -41,7 +43,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.JavaConverters.collectionAsScalaIterable(backing.keySet) def all = backing.keySet.asScala
def toList = all.toList def toList = all.toList
def isEmpty = backing.isEmpty def isEmpty = backing.isEmpty

View File

@ -18,7 +18,7 @@ sealed trait KList[+M[_]] {
def transform[N[_]](f: M ~> N): Transform[N] def transform[N[_]](f: M ~> N): Transform[N]
/** Folds this list using a function that operates on the homogeneous type of the elements of this list. */ /** Folds this list using a function that operates on the homogeneous type of the elements of this list. */
def foldr[B](f: (M[_], B) => B, init: B): B = init // had trouble defining it in KNil def foldr[B](f: (M[_], B) => B, init: B): B
/** Applies `f` to the elements of this list in the applicative functor defined by `ap`. */ /** Applies `f` to the elements of this list in the applicative functor defined by `ap`. */
def apply[N[x] >: M[x], Z](f: Transform[Id] => Z)(implicit ap: Applicative[N]): N[Z] def apply[N[x] >: M[x], Z](f: Transform[Id] => Z)(implicit ap: Applicative[N]): N[Z]
@ -54,13 +54,14 @@ final case class KCons[H, +T <: KList[M], +M[_]](head: M[H], tail: T) extends KL
override def foldr[B](f: (M[_], B) => B, init: B): B = f(head, tail.foldr(f, init)) override def foldr[B](f: (M[_], B) => B, init: B): B = f(head, tail.foldr(f, init))
} }
sealed abstract class KNil extends KList[Nothing] { sealed abstract class KNil extends KList[NothingK] {
final type Transform[N[_]] = KNil final type Transform[N[_]] = KNil
final def transform[N[_]](f: Nothing ~> N): Transform[N] = KNil final def transform[N[_]](f: NothingK ~> N): Transform[N] = KNil
final def foldr[B](f: (NothingK[_], B) => B, init: B): B = init
final def toList = Nil final def toList = Nil
final def apply[N[x], Z](f: KNil => Z)(implicit ap: Applicative[N]): N[Z] = ap.pure(f(KNil)) final def apply[N[x], Z](f: KNil => Z)(implicit ap: Applicative[N]): N[Z] = ap.pure(f(KNil))
final def traverse[N[_], P[_]](f: Nothing ~> (N P)#l)(implicit np: Applicative[N]): N[KNil] = final def traverse[N[_], P[_]](f: NothingK ~> (N P)#l)(implicit np: Applicative[N]): N[KNil] =
np.pure(KNil) np.pure(KNil)
} }

View File

@ -65,7 +65,7 @@ object Signals {
} }
// Must only be referenced using a // Must only be referenced using a
// try { } catch { case e: LinkageError => ... } // try { } catch { case _: LinkageError => ... }
// block to // block to
private final class Signals0 { private final class Signals0 {
def supported(signal: String): Boolean = { def supported(signal: String): Boolean = {

View File

@ -9,6 +9,7 @@ package sbt.internal.util
trait TypeFunctions { trait TypeFunctions {
type Id[X] = X type Id[X] = X
type NothingK[X] = Nothing
sealed trait Const[A] { type Apply[B] = A } sealed trait Const[A] { type Apply[B] = A }
sealed trait ConstK[A] { type l[L[x]] = A } sealed trait ConstK[A] { type l[L[x]] = A }
sealed trait Compose[A[_], B[_]] { type Apply[T] = A[B[T]] } sealed trait Compose[A[_], B[_]] { type Apply[T] = A[B[T]] }

View File

@ -7,8 +7,7 @@
package sbt.internal.util package sbt.internal.util
import org.scalacheck._ import org.scalacheck._, Prop._
import Prop._
object SettingsTest extends Properties("settings") { object SettingsTest extends Properties("settings") {
val settingsExample: SettingsExample = SettingsExample() val settingsExample: SettingsExample = SettingsExample()
@ -160,7 +159,7 @@ object SettingsTest extends Properties("settings") {
final def checkCircularReferences(intermediate: Int): Prop = { final def checkCircularReferences(intermediate: Int): Prop = {
val ccr = new CCR(intermediate) val ccr = new CCR(intermediate)
try { evaluate(setting(chk, ccr.top) :: Nil); false } catch { try { evaluate(setting(chk, ccr.top) :: Nil); false } catch {
case e: java.lang.Exception => true case _: java.lang.Exception => true
} }
} }
@ -197,18 +196,18 @@ object SettingsTest extends Properties("settings") {
def evaluate(settings: Seq[Setting[_]]): Settings[Scope] = def evaluate(settings: Seq[Setting[_]]): Settings[Scope] =
try { make(settings)(delegates, scopeLocal, showFullKey) } catch { try { make(settings)(delegates, scopeLocal, showFullKey) } catch {
case e: Throwable => e.printStackTrace; throw e case e: Throwable => e.printStackTrace(); throw e
} }
} }
// This setup is a workaround for module synchronization issues // This setup is a workaround for module synchronization issues
final class CCR(intermediate: Int) { final class CCR(intermediate: Int) {
import SettingsTest.settingsExample._ import SettingsTest.settingsExample._
lazy val top = iterate(value(intermediate), intermediate) lazy val top = iterate(value(intermediate))
def iterate(init: Initialize[Int], i: Int): Initialize[Int] = def iterate(init: Initialize[Int]): Initialize[Int] =
bind(init) { t => bind(init) { t =>
if (t <= 0) if (t <= 0)
top top
else else
iterate(value(t - 1), t - 1) iterate(value(t - 1))
} }
} }