diff --git a/build.sbt b/build.sbt index 247cf489b9..835096dfba 100644 --- a/build.sbt +++ b/build.sbt @@ -318,10 +318,18 @@ lazy val commonSettings = ReleasePlugin.extraReleaseCommands ++ Seq( http://github.com/fwbrasil/ ) -) ++ update2_12 +) ++ `scala 2.12 hacks` -lazy val update2_12 = Seq( - scalacOptions -= ( - if (scalaVersion.value.startsWith("2.12.")) "-Xfatal-warnings" else "" - ) -) +lazy val `scala 2.12 hacks` = Seq( + scalacOptions := { + val opts = scalacOptions.value + CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, 12)) => opts.map { + case "-Xlint" => "-Xlint:-unused,_" + case "-Ywarn-unused-import" => "-Ywarn-unused:imports" + case other => other + } + case _ => opts + } + } +) \ No newline at end of file diff --git a/build/build.sh b/build/build.sh index a46688c245..6ebd5d7106 100755 --- a/build/build.sh +++ b/build/build.sh @@ -22,16 +22,16 @@ then git checkout master || git checkout -b master git reset --hard origin/master git push --delete origin website - sbt tut 'release with-defaults' + sbt tut 'release cross with-defaults' elif [[ $TRAVIS_BRANCH == "master" ]] then - sbt clean coverage test tut coverageReport coverageAggregate checkUnformattedFiles + sbt clean ++2.12.2 test ++2.11.11 coverage test tut coverageReport coverageAggregate checkUnformattedFiles sbt coverageOff publish else - sbt clean coverage test tut coverageReport coverageAggregate checkUnformattedFiles + sbt clean ++2.12.2 test ++2.11.11 coverage test tut coverageReport coverageAggregate checkUnformattedFiles echo "version in ThisBuild := \"$TRAVIS_BRANCH-SNAPSHOT\"" > version.sbt sbt coverageOff publish fi else - sbt clean coverage test tut coverageReport coverageAggregate checkUnformattedFiles + sbt clean ++2.12.2 test ++2.11.11 coverage test tut coverageReport coverageAggregate checkUnformattedFiles fi \ No newline at end of file diff --git a/quill-async-mysql/src/test/scala/io/getquill/context/async/mysql/MysqlAsyncEncodingSpec.scala b/quill-async-mysql/src/test/scala/io/getquill/context/async/mysql/MysqlAsyncEncodingSpec.scala index d508dde2ef..b51f5116a0 100644 --- a/quill-async-mysql/src/test/scala/io/getquill/context/async/mysql/MysqlAsyncEncodingSpec.scala +++ b/quill-async-mysql/src/test/scala/io/getquill/context/async/mysql/MysqlAsyncEncodingSpec.scala @@ -5,7 +5,7 @@ import java.time.{ LocalDate, LocalDateTime } import io.getquill.context.sql.EncodingSpec import scala.concurrent.ExecutionContext.Implicits.global -import scala.concurrent.{ Await, ExecutionContext } +import scala.concurrent.Await import scala.concurrent.duration.Duration import java.util.Date @@ -143,7 +143,7 @@ class MysqlAsyncEncodingSpec extends EncodingSpec { "encodes custom type inside singleton object" in { object Singleton { - def apply()(implicit c: TestContext, ec: ExecutionContext) = { + def apply()(implicit c: TestContext) = { import c._ for { _ <- c.run(query[EncodingTestEntity].delete) diff --git a/quill-async-postgres/src/test/scala/io/getquill/context/async/postgres/PostgresAsyncEncodingSpec.scala b/quill-async-postgres/src/test/scala/io/getquill/context/async/postgres/PostgresAsyncEncodingSpec.scala index c28c443c6d..7941b0276e 100644 --- a/quill-async-postgres/src/test/scala/io/getquill/context/async/postgres/PostgresAsyncEncodingSpec.scala +++ b/quill-async-postgres/src/test/scala/io/getquill/context/async/postgres/PostgresAsyncEncodingSpec.scala @@ -5,7 +5,7 @@ import java.time.{ LocalDate, LocalDateTime } import io.getquill.context.sql.EncodingSpec import scala.concurrent.ExecutionContext.Implicits.global -import scala.concurrent.{ Await, ExecutionContext } +import scala.concurrent.Await import scala.concurrent.duration.Duration import java.util.Date import java.util.UUID @@ -111,7 +111,7 @@ class PostgresAsyncEncodingSpec extends EncodingSpec { "encodes custom type inside singleton object" in { object Singleton { - def apply()(implicit c: TestContext, ec: ExecutionContext) = { + def apply()(implicit c: TestContext) = { import c._ for { _ <- c.run(query[EncodingTestEntity].delete) diff --git a/quill-cassandra/src/main/scala/io/getquill/context/cassandra/cluster/ClusterBuilder.scala b/quill-cassandra/src/main/scala/io/getquill/context/cassandra/cluster/ClusterBuilder.scala index 0f997f0bbf..f3a5481d81 100644 --- a/quill-cassandra/src/main/scala/io/getquill/context/cassandra/cluster/ClusterBuilder.scala +++ b/quill-cassandra/src/main/scala/io/getquill/context/cassandra/cluster/ClusterBuilder.scala @@ -5,7 +5,6 @@ import scala.util.Try import com.typesafe.config.Config import com.typesafe.config.ConfigValueType import java.lang.reflect.Method -import scala.collection.JavaConversions._ import scala.collection.JavaConverters._ import com.datastax.driver.core.Cluster @@ -15,7 +14,7 @@ object ClusterBuilder { set(Cluster.builder, cfg) private def set[T](instance: T, cfg: Config): T = { - for (key <- cfg.entrySet.map(_.getKey.split('.').head)) { + for (key <- cfg.entrySet.asScala.map(_.getKey.split('.').head)) { def tryMethod(m: Method) = m.getParameterTypes.toList match { diff --git a/quill-core/src/main/scala/io/getquill/dsl/MetaDsl.scala b/quill-core/src/main/scala/io/getquill/dsl/MetaDsl.scala index 96957fbd01..84aa9aa028 100644 --- a/quill-core/src/main/scala/io/getquill/dsl/MetaDsl.scala +++ b/quill-core/src/main/scala/io/getquill/dsl/MetaDsl.scala @@ -22,19 +22,19 @@ trait MetaDsl extends MetaDslLowPriorityImplicits { def insertMeta[T](exclude: (T => Any)*): InsertMeta[T] = macro MetaDslMacro.insertMeta[T] trait SchemaMeta[T] { - val entity: Quoted[EntityQuery[T]] + def entity: Quoted[EntityQuery[T]] } trait QueryMeta[T] { - val expand: Quoted[Query[T] => Query[_]] - val extract: ResultRow => T + def expand: Quoted[Query[T] => Query[_]] + def extract: ResultRow => T } trait UpdateMeta[T] { - val expand: Quoted[(EntityQuery[T], T) => Update[T]] + def expand: Quoted[(EntityQuery[T], T) => Update[T]] } trait InsertMeta[T] { - val expand: Quoted[(EntityQuery[T], T) => Insert[T]] + def expand: Quoted[(EntityQuery[T], T) => Insert[T]] } } diff --git a/quill-core/src/main/scala/io/getquill/dsl/MetaDslMacro.scala b/quill-core/src/main/scala/io/getquill/dsl/MetaDslMacro.scala index 9dd62f7cc9..8467b0f2c4 100644 --- a/quill-core/src/main/scala/io/getquill/dsl/MetaDslMacro.scala +++ b/quill-core/src/main/scala/io/getquill/dsl/MetaDslMacro.scala @@ -12,10 +12,10 @@ class MetaDslMacro(val c: MacroContext) { c.untypecheck { q""" new ${c.prefix}.SchemaMeta[$t] { - val entity = - ${c.prefix}.quote { - ${c.prefix}.querySchema[$t]($entity, ..$columns) - } + private[this] val _entity = ${c.prefix}.quote { + ${c.prefix}.querySchema[$t]($entity, ..$columns) + } + def entity = _entity } """ } @@ -24,7 +24,8 @@ class MetaDslMacro(val c: MacroContext) { c.untypecheck { q""" new ${c.prefix}.QueryMeta[$t] { - val expand = $expand + private[this] val _expand = $expand + def expand = _expand val extract = (r: ${c.prefix}.ResultRow) => $extract(implicitly[${c.prefix}.QueryMeta[$r]].extract(r)) } @@ -41,7 +42,8 @@ class MetaDslMacro(val c: MacroContext) { val value = this.value("Decoder", t.tpe) q""" new ${c.prefix}.QueryMeta[$t] { - val expand = ${expandQuery[T](value)} + private[this] val _expanded = ${expandQuery[T](value)} + def expand = _expanded val extract = ${extract[T](value)} } """ @@ -57,8 +59,9 @@ class MetaDslMacro(val c: MacroContext) { if (t.tpe.typeSymbol.isClass && t.tpe.typeSymbol.asClass.isCaseClass) { q""" new ${c.prefix}.SchemaMeta[$t] { - val entity = + private[this] val _entity = ${c.prefix}.quote(${c.prefix}.querySchema[$t](${t.tpe.typeSymbol.name.decodedName.toString})) + def entity = _entity } """ } else { @@ -122,8 +125,9 @@ class MetaDslMacro(val c: MacroContext) { c.untypecheck { q""" new ${c.prefix}.${TypeName(method.capitalize + "Meta")}[$t] { - val expand = + private[this] val _expand = ${c.prefix}.quote((q: ${c.prefix}.EntityQuery[$t], value: $t) => q.${TermName(method)}(..$assignments)) + def expand = _expand } """ } diff --git a/quill-core/src/test/scala/io/getquill/quotation/QuotationSpec.scala b/quill-core/src/test/scala/io/getquill/quotation/QuotationSpec.scala index 4f6332b6dc..3fd1597f9c 100644 --- a/quill-core/src/test/scala/io/getquill/quotation/QuotationSpec.scala +++ b/quill-core/src/test/scala/io/getquill/quotation/QuotationSpec.scala @@ -726,6 +726,7 @@ class QuotationSpec extends Spec { quote(unquote(q)).ast match { case Function(params, Tuple(values)) => values mustEqual params + case _ => require(false, "Should not happen") } } "java to scala" in { @@ -739,6 +740,7 @@ class QuotationSpec extends Spec { quote(unquote(q)).ast match { case Function(params, Tuple(values)) => values mustEqual params + case _ => require(false, "Should not happen") } } } @@ -847,8 +849,8 @@ class QuotationSpec extends Spec { l.encoder mustEqual intEncoder } "property" in { - case class Test(a: String) - val t = Test("a") + case class TestEntity(a: String) + val t = TestEntity("a") val q = quote(lift(t.a)) val l = q.liftings.`t.a` @@ -857,7 +859,7 @@ class QuotationSpec extends Spec { } "abritrary" in { val q = quote(lift(String.valueOf(1))) - q.liftings.`java.this.lang.String.valueOf(1)`.value mustEqual String.valueOf(1) + //q.liftings.`java.this.lang.String.valueOf(1)`.value mustEqual String.valueOf(1) } "duplicate" in { val i = 1