Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Commit

Permalink
Omit the compiler warnings of main dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrs committed Dec 21, 2019
1 parent cfc25c8 commit e11c63b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 32 deletions.
25 changes: 8 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ val preferences =
ScalariformKeys.preferences := ScalariformKeys.preferences.value
.setPreference(DanglingCloseParenthesis, Force)

lazy val root = project.in(file("."))
.settings(name := "agni")
lazy val agni = project.in(file("."))
.settings(allSettings)
.settings(noPublishSettings)
.aggregate(core, `twitter-util`, monix, `cats-effect`, examples)
Expand Down Expand Up @@ -105,9 +104,7 @@ lazy val publishSettings = Seq(
)

lazy val noPublishSettings = Seq(
publish := ((): Unit),
publishLocal := ((): Unit),
publishArtifact := false
skip in publish := true
)

lazy val crossVersionSharedSources: Seq[Setting[_]] =
Expand All @@ -133,16 +130,14 @@ lazy val core = project.in(file("core"))
)
.settings(
description := "agni core",
moduleName := "agni-core",
name := "core"
moduleName := "agni-core"
)

lazy val `twitter-util` = project.in(file("twitter-util"))
.settings(allSettings)
.settings(
description := "agni twitter-util",
moduleName := "agni-twitter-util",
name := "twitter-util",
moduleName := "agni-twitter-util"
)
.settings(
libraryDependencies ++= Seq(
Expand All @@ -155,8 +150,7 @@ lazy val monix = project.in(file("monix"))
.settings(allSettings)
.settings(
description := "agni monix",
moduleName := "agni-monix",
name := "monix",
moduleName := "agni-monix"
)
.settings(
libraryDependencies ++= Seq(
Expand All @@ -170,8 +164,7 @@ lazy val `cats-effect` = project.in(file("cats-effect"))
.settings(allSettings)
.settings(
description := "agni cats-effect",
moduleName := "agni-cats-effect",
name := "cats-effect",
moduleName := "agni-cats-effect"
)
.settings(
libraryDependencies ++= Seq(
Expand All @@ -185,8 +178,7 @@ lazy val benchmarks = project.in(file("benchmarks"))
.settings(noPublishSettings)
.settings(
description := "agni benchmarks",
moduleName := "agni-benchmarks",
name := "benchmarks",
moduleName := "agni-benchmarks"
)
.settings(
scalacOptions ++= Seq(
Expand All @@ -203,8 +195,7 @@ lazy val examples = project.in(file("examples"))
.settings(noPublishSettings)
.settings(
description := "agni examples",
moduleName := "agni-examples",
name := "examples",
moduleName := "agni-examples"
)
.settings(
libraryDependencies ++= Seq(
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/scala/agni/Serializer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.nio.ByteBuffer
import java.time.{ Instant, LocalDate, ZonedDateTime }
import java.util.UUID

import agni.internal.ScalaVersionSpecifics._
import cats.instances.either._
import cats.syntax.apply._
import cats.syntax.either._
Expand All @@ -13,7 +14,6 @@ import com.datastax.oss.driver.api.core.`type`.codec.TypeCodecs
import com.datastax.oss.driver.api.core.data.CqlDuration

import scala.annotation.tailrec
import scala.collection.generic.IsTraversableOnce
import scala.collection.mutable

trait Serializer[A] {
Expand All @@ -23,7 +23,7 @@ trait Serializer[A] {

def contramap[B](f: B => A): Serializer[B] = new Serializer[B] {
override def apply(value: B, version: ProtocolVersion): Either[Throwable, ByteBuffer] =
self.apply(f(value), version)
self(f(value), version)
}
}

Expand All @@ -35,7 +35,7 @@ object Serializer {
override def apply(value: Option[A], version: ProtocolVersion): Either[Throwable, ByteBuffer] =
value match {
case None => Right(null)
case Some(v) => A.apply(v, version)
case Some(v) => A(v, version)
}
}

Expand Down Expand Up @@ -167,18 +167,18 @@ object Serializer {
implicit def serializeTraversableOnce[A0, C[_]](
implicit
A: Serializer[A0],
is: IsTraversableOnce[C[A0]] { type A = A0 }
is: IsIterableOnce.Aux[C[A0], A0]
): Serializer[C[A0]] =
new Serializer[C[A0]] {
override def apply(value: C[A0], version: ProtocolVersion): Either[Throwable, ByteBuffer] = {
if (value == null) Left(new NullPointerException) else {
val items = mutable.ArrayBuilder.make[ByteBuffer]
val it = is.conversion(value).toIterator
val it = is(value).iterator

@tailrec def go(toAllocate: Int): Either[Throwable, (Array[ByteBuffer], Int)] = {
if (!it.hasNext) (items.result(), toAllocate).asRight
else {
A.apply(it.next(), version) match {
A(it.next(), version) match {
case Right(v) =>
items += v
go(toAllocate + 4 + v.remaining())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
package agni.internal

import scala.collection.generic.CanBuildFrom
import scala.collection.mutable
import scala.collection.generic._
import scala.collection.{ mutable, GenTraversableOnce }

private[agni] object ScalaVersionSpecifics {
private[agni] type Factory[-E, +T] = CanBuildFrom[Nothing, E, T]

implicit private[agni] class FactoryOps[F, E, T](val bf: Factory[E, T]) extends AnyVal {
def newBuilder: mutable.Builder[E, T] = bf.apply()
private[agni] implicit class FactoryOps[F, E, T](val underlying: Factory[E, T]) extends AnyVal {
def newBuilder: mutable.Builder[E, T] = underlying.apply()
}

object IsIterableOnce {
type Aux[Repr, A0] = IsTraversableOnce[Repr] { type A = A0 }
}

private[agni] implicit class IsIterableOnceOps[Repr, A](val underlying: IsIterableOnce.Aux[Repr, A]) extends AnyVal {
def apply(coll: Repr): GenTraversableOnce[A] = underlying.conversion(coll)
}
private[agni] implicit class GenTraversableOnceOps[A](val underlying: GenTraversableOnce[A]) extends AnyVal {
def iterator: Iterator[A] = underlying.toIterator
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ package agni.internal

private[agni] object ScalaVersionSpecifics {
private[agni] type Factory[-E, +T] = scala.collection.Factory[E, T]

object IsIterableOnce {
type Aux[A0, B] = scala.collection.generic.IsIterableOnce[A0] { type A = B }
}
}
10 changes: 5 additions & 5 deletions core/src/test/scala/agni/TypedSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ trait TypedSuite extends FunSuite with Checkers {
type T17 = (Option[Int], String, Int, Long, Float, Double, BigDecimal, Byte, Short, BigInt, UUID, ByteBuffer, InetAddress, LocalDate, Instant, CqlDuration, List[Int])
type T18 = (Option[Int], String, Int, Long, Float, Double, BigDecimal, Byte, Short, BigInt, UUID, ByteBuffer, InetAddress, LocalDate, Instant, CqlDuration, List[Int], Vector[String])
type T19 = (Option[Int], String, Int, Long, Float, Double, BigDecimal, Byte, Short, BigInt, UUID, ByteBuffer, InetAddress, LocalDate, Instant, CqlDuration, List[Int], Vector[String], Set[Double])
type T20 = (Option[Int], String, Int, Long, Float, Double, BigDecimal, Byte, Short, BigInt, UUID, ByteBuffer, InetAddress, LocalDate, Instant, CqlDuration, List[Int], Vector[String], Set[Double], Stream[Float])
type T21 = (Option[Int], String, Int, Long, Float, Double, BigDecimal, Byte, Short, BigInt, UUID, ByteBuffer, InetAddress, LocalDate, Instant, CqlDuration, List[Int], Vector[String], Set[Double], Stream[Float], Map[Int, String])
type T22 = (Option[Int], String, Int, Long, Float, Double, BigDecimal, Byte, Short, BigInt, UUID, ByteBuffer, InetAddress, LocalDate, Instant, CqlDuration, List[Int], Vector[String], Set[Double], Stream[Float], Map[Int, String], TupleValue)
type T22_2 = (Option[Int], String, Int, Long, Float, Double, BigDecimal, Byte, Short, BigInt, UUID, ByteBuffer, InetAddress, LocalDate, Instant, CqlDuration, List[Int], Vector[String], Set[Double], Stream[Float], Map[Int, String], UdtValue)
type T20 = (Option[Int], String, Int, Long, Float, Double, BigDecimal, Byte, Short, BigInt, UUID, ByteBuffer, InetAddress, LocalDate, Instant, CqlDuration, List[Int], Vector[String], Set[Double], Iterable[Float])
type T21 = (Option[Int], String, Int, Long, Float, Double, BigDecimal, Byte, Short, BigInt, UUID, ByteBuffer, InetAddress, LocalDate, Instant, CqlDuration, List[Int], Vector[String], Set[Double], Iterable[Float], Map[Int, String])
type T22 = (Option[Int], String, Int, Long, Float, Double, BigDecimal, Byte, Short, BigInt, UUID, ByteBuffer, InetAddress, LocalDate, Instant, CqlDuration, List[Int], Vector[String], Set[Double], Iterable[Float], Map[Int, String], TupleValue)
type T22_2 = (Option[Int], String, Int, Long, Float, Double, BigDecimal, Byte, Short, BigInt, UUID, ByteBuffer, InetAddress, LocalDate, Instant, CqlDuration, List[Int], Vector[String], Set[Double], Iterable[Float], Map[Int, String], UdtValue)

type IDV = Record.`'foo -> Int, 'bar -> Double, 'quux -> Vector[Int]`.T

Expand Down Expand Up @@ -62,7 +62,7 @@ object TypedSuite {
listInt: List[Int],
vectorString: Vector[String],
setDouble: Set[Double],
streamFloat: Stream[Float],
streamFloat: Iterable[Float],
mapIntString: Map[Int, String],
tupleValue: TupleValue,
udtValue: UdtValue
Expand Down

0 comments on commit e11c63b

Please sign in to comment.