-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
WIP: Add Dotty build for kernel only #2629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ lazy val commonSettings = Seq( | |
extraDirs("-2.12-") | ||
case Some((2, y)) if y >= 13 => | ||
extraDirs("-2.13+") | ||
case Some((0, 10)) => | ||
extraDirs("-0.10") | ||
case _ => Nil | ||
} | ||
}, | ||
|
@@ -382,6 +384,7 @@ lazy val docs = project | |
.settings(moduleName := "cats-docs") | ||
.settings(catsSettings) | ||
.settings(noPublishSettings) | ||
.settings(noDottySettings) | ||
.settings(docSettings) | ||
.settings(commonJvmSettings) | ||
.dependsOn(coreJVM, freeJVM, kernelLawsJVM, lawsJVM, testkitJVM) | ||
|
@@ -391,13 +394,15 @@ lazy val cats = project | |
.settings(moduleName := "root") | ||
.settings(catsSettings) | ||
.settings(noPublishSettings) | ||
.settings(noDottySettings) | ||
.aggregate(catsJVM, catsJS) | ||
.dependsOn(catsJVM, catsJS, testsJVM % "test-internal -> test") | ||
|
||
lazy val catsJVM = project | ||
.in(file(".catsJVM")) | ||
.settings(moduleName := "cats") | ||
.settings(noPublishSettings) | ||
.settings(noDottySettings) | ||
.settings(catsSettings) | ||
.settings(commonJvmSettings) | ||
.aggregate(macrosJVM, | ||
|
@@ -432,6 +437,7 @@ lazy val catsJS = project | |
.in(file(".catsJS")) | ||
.settings(moduleName := "cats") | ||
.settings(noPublishSettings) | ||
.settings(noDottySettings) | ||
.settings(catsSettings) | ||
.settings(commonJsSettings) | ||
.aggregate(macrosJS, | ||
|
@@ -466,6 +472,7 @@ lazy val macros = crossProject(JSPlatform, JVMPlatform) | |
.crossType(CrossType.Pure) | ||
.settings(moduleName := "cats-macros", name := "Cats macros") | ||
.settings(catsSettings) | ||
.settings(noDottySettings) | ||
.jsSettings(commonJsSettings) | ||
.jvmSettings(commonJvmSettings) | ||
.jsSettings(coverageEnabled := false) | ||
|
@@ -483,9 +490,14 @@ lazy val kernel = crossProject(JSPlatform, JVMPlatform) | |
.settings(scoverageSettings) | ||
.settings(sourceGenerators in Compile += (sourceManaged in Compile).map(KernelBoiler.gen).taskValue) | ||
.settings(includeGeneratedSrc) | ||
.jsSettings(commonJsSettings) | ||
.jsSettings(commonJsSettings ++ noDottySettings) | ||
.jvmSettings(commonJvmSettings ++ mimaSettings("cats-kernel")) | ||
.settings(libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion(scalaVersion.value) % "test") | ||
.settings(libraryDependencies ++= { | ||
if (!isDotty.value) | ||
Seq("org.scalacheck" %%% "scalacheck" % scalaCheckVersion(scalaVersion.value) % "test") | ||
else | ||
Seq() | ||
}) | ||
|
||
lazy val kernelJVM = kernel.jvm | ||
lazy val kernelJS = kernel.js | ||
|
@@ -496,6 +508,7 @@ lazy val kernelLaws = crossProject(JSPlatform, JVMPlatform) | |
.settings(moduleName := "cats-kernel-laws", name := "Cats kernel laws") | ||
.settings(commonSettings) | ||
.settings(publishSettings) | ||
.settings(noDottySettings) | ||
.settings(scoverageSettings) | ||
.settings(disciplineDependencies) | ||
.settings(testingDependencies) | ||
|
@@ -512,6 +525,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform) | |
.dependsOn(macros, kernel) | ||
.settings(moduleName := "cats-core", name := "Cats core") | ||
.settings(catsSettings) | ||
.settings(noDottySettings) | ||
.settings(sourceGenerators in Compile += (sourceManaged in Compile).map(Boilerplate.gen).taskValue) | ||
.settings(includeGeneratedSrc) | ||
.settings(libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion(scalaVersion.value) % "test") | ||
|
@@ -526,6 +540,7 @@ lazy val laws = crossProject(JSPlatform, JVMPlatform) | |
.dependsOn(macros, kernel, core, kernelLaws) | ||
.settings(moduleName := "cats-laws", name := "Cats laws") | ||
.settings(catsSettings) | ||
.settings(noDottySettings) | ||
.settings(disciplineDependencies) | ||
.settings(testingDependencies) | ||
.jsSettings(commonJsSettings) | ||
|
@@ -540,6 +555,7 @@ lazy val free = crossProject(JSPlatform, JVMPlatform) | |
.dependsOn(macros, core, tests % "test-internal -> test") | ||
.settings(moduleName := "cats-free", name := "Cats Free") | ||
.settings(catsSettings) | ||
.settings(noDottySettings) | ||
.jsSettings(commonJsSettings) | ||
.jvmSettings(commonJvmSettings ++ mimaSettings("cats-free")) | ||
|
||
|
@@ -552,6 +568,7 @@ lazy val tests = crossProject(JSPlatform, JVMPlatform) | |
.settings(moduleName := "cats-tests") | ||
.settings(catsSettings) | ||
.settings(noPublishSettings) | ||
.settings(noDottySettings) | ||
.jsSettings(commonJsSettings) | ||
.jvmSettings(commonJvmSettings) | ||
|
||
|
@@ -566,6 +583,7 @@ lazy val testkit = crossProject(JSPlatform, JVMPlatform) | |
.settings(moduleName := "cats-testkit") | ||
.settings(catsSettings) | ||
.settings(disciplineDependencies) | ||
.settings(noDottySettings) | ||
.settings(libraryDependencies += "org.scalatest" %%% "scalatest" % scalatestVersion(scalaVersion.value)) | ||
.jsSettings(commonJsSettings) | ||
.jvmSettings(commonJvmSettings) | ||
|
@@ -585,6 +603,7 @@ lazy val alleycatsCore = crossProject(JSPlatform, JVMPlatform) | |
) | ||
.settings(catsSettings) | ||
.settings(publishSettings) | ||
.settings(noDottySettings) | ||
.settings(scoverageSettings) | ||
.settings(includeGeneratedSrc) | ||
.jsSettings(commonJsSettings) | ||
|
@@ -601,6 +620,7 @@ lazy val alleycatsLaws = crossProject(JSPlatform, JVMPlatform) | |
.settings(moduleName := "alleycats-laws", name := "Alleycats laws") | ||
.settings(catsSettings) | ||
.settings(publishSettings) | ||
.settings(noDottySettings) | ||
.settings(scoverageSettings) | ||
.settings(disciplineDependencies) | ||
.settings(testingDependencies) | ||
|
@@ -619,6 +639,7 @@ lazy val alleycatsTests = crossProject(JSPlatform, JVMPlatform) | |
.settings(moduleName := "alleycats-tests") | ||
.settings(catsSettings) | ||
.settings(noPublishSettings) | ||
.settings(noDottySettings) | ||
.jsSettings(commonJsSettings) | ||
.jvmSettings(commonJvmSettings) | ||
|
||
|
@@ -632,6 +653,7 @@ lazy val bench = project | |
.settings(moduleName := "cats-bench") | ||
.settings(catsSettings) | ||
.settings(noPublishSettings) | ||
.settings(noDottySettings) | ||
.settings(commonJvmSettings) | ||
.settings(coverageEnabled := false) | ||
.settings( | ||
|
@@ -646,6 +668,7 @@ lazy val bench = project | |
lazy val binCompatTest = project | ||
.disablePlugins(CoursierPlugin) | ||
.settings(noPublishSettings) | ||
.settings(noDottySettings) | ||
.settings( | ||
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.8"), | ||
libraryDependencies ++= List( | ||
|
@@ -665,6 +688,7 @@ lazy val js = project | |
.dependsOn(macrosJS, coreJS, testsJS % "test-internal -> test") | ||
.settings(moduleName := "cats-js") | ||
.settings(catsSettings) | ||
.settings(noDottySettings) | ||
.settings(commonJsSettings) | ||
.enablePlugins(ScalaJSPlugin) | ||
|
||
|
@@ -673,6 +697,7 @@ lazy val jvm = project | |
.dependsOn(macrosJVM, coreJVM, testsJVM % "test-internal -> test") | ||
.settings(moduleName := "cats-jvm") | ||
.settings(catsSettings) | ||
.settings(noDottySettings) | ||
.settings(commonJvmSettings) | ||
|
||
lazy val publishSettings = Seq( | ||
|
@@ -790,6 +815,10 @@ addCommandAlias("prePR", ";fmt;validateBC") | |
|
||
addCommandAlias("gitSnapshots", ";set version in ThisBuild := git.gitDescribedVersion.value.get + \"-SNAPSHOT\"") | ||
|
||
lazy val noDottySettings = Seq( | ||
crossScalaVersions ~= {_.filterNot(Set("0.10.0-RC1"))} | ||
) | ||
|
||
lazy val noPublishSettings = Seq( | ||
publish := {}, | ||
publishLocal := {}, | ||
|
@@ -878,7 +907,8 @@ lazy val warnUnusedImport = Seq( | |
Seq("-Ywarn-unused-import") | ||
case Some((2, n)) if n >= 12 => | ||
Seq("-Ywarn-unused:imports") | ||
|
||
case Some((0, 10)) => | ||
Seq("-Ywarn-unused:imports") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That setting doesn't exist in Dotty currently |
||
} | ||
}, | ||
scalacOptions in (Compile, console) ~= { _.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports")) }, | ||
|
@@ -906,6 +936,7 @@ lazy val xlint = Seq( | |
scalacOptions += { | ||
CrossVersion.partialVersion(scalaVersion.value) match { | ||
case Some((2, scalaMajor)) if scalaMajor >= 12 => "-Xlint:-unused,_" | ||
case Some((0, 10)) => "-Xlint:-unused,_" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no -Xlint in Dotty currently (and I hope scalafix can completely replace -Xlint) |
||
case _ => "-Xlint" | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package cats.kernel | ||
package compat | ||
|
||
private[kernel] object TraversableOnce { | ||
def reduceOption[A, A1 >: A](as: TraversableOnce[A], op: (A1, A1) => A1): Option[A1] = | ||
as.reduceOption(op) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package cats.kernel | ||
package compat | ||
|
||
import scala.collection.mutable | ||
|
||
abstract private[kernel] class WrappedMutableMapBase[K, V](m: mutable.Map[K, V]) extends Map[K, V] { | ||
override def updated[V2 >: V](key: K, value: V2): Map[K, V2] = m.toMap + ((key, value)) | ||
def +[V2 >: V](kv: (K, V2)): Map[K, V2] = m.toMap + kv | ||
def -(key: K): Map[K, V] = m.toMap - key | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.25") | |
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.8") | ||
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1") | ||
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") | ||
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.4") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Latest is 0.2.6 (looks like we forgot to update the example projects) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed... my proof that I did Read The Fantastic Manual, but missed the important bit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add
.withDottyCompat(scalaVersion.value)
you should be able to keep this dependency when compiling with Dotty too (https://github.com/lampepfl/dotty-example-project#getting-your-project-to-compile-with-dotty)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh...I missed that!! Cool