-
Notifications
You must be signed in to change notification settings - Fork 150
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
Mix scala 2 and 3 macros #395
base: master
Are you sure you want to change the base?
Changes from all commits
7b14325
947a593
0a43847
724cb52
519b37b
69038cf
94740e3
beff0d6
719ad73
0f8dfca
ad41604
58feb27
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version = 3.7.8 | ||
version = 3.7.10 | ||
runner.dialect = Scala213Source3 | ||
style = defaultWithAlign | ||
maxColumn = 100 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ import sbtbuildinfo.BuildInfoPlugin.autoImport._ | |
import sbtcrossproject.CrossPlugin.autoImport.{CrossType, crossProject} | ||
|
||
lazy val scala_2_12Version = "2.12.18" | ||
lazy val scala_2_13Version = "2.13.11" | ||
lazy val scala_3Version = "3.3.0" | ||
lazy val scala_2_13Version = "2.13.13" | ||
lazy val scala_3Version = "3.3.4" | ||
lazy val scalaVersionsAll = Seq(scala_2_12Version, scala_2_13Version, scala_3Version) | ||
|
||
lazy val theScalaVersion = scala_2_12Version | ||
|
@@ -108,11 +108,14 @@ lazy val macros = crossProject(JSPlatform, JVMPlatform, NativePlatform) | |
name := "enumeratum-macros", | ||
version := Versions.Macros.head, | ||
crossScalaVersions := scalaVersionsAll, // eventually move this to aggregateProject once more 2.13 libs are out | ||
libraryDependencies += { | ||
libraryDependencies ++= { | ||
if (scalaBinaryVersion.value == "3") { | ||
"org.scala-lang" %% "scala3-compiler" % scalaVersion.value % Provided | ||
Seq( | ||
"org.scala-lang" %% "scala3-compiler" % scalaVersion.value % Provided, | ||
"org.scala-lang" % "scala-reflect" % scala_2_13Version, | ||
) | ||
} else { | ||
"org.scala-lang" % "scala-reflect" % scalaVersion.value | ||
Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value) | ||
} | ||
}, | ||
libraryDependencies += scalaXmlTest | ||
|
@@ -141,7 +144,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform) | |
if (useLocalVersion) { | ||
Seq.empty | ||
} else { | ||
Seq("com.beachape" %% "enumeratum-macros" % Versions.Macros.stable) | ||
Seq("com.beachape" %% "enumeratum-macros" % Versions.Macros.head) | ||
} | ||
}, | ||
libraryDependencies += scalaXmlTest | ||
|
@@ -461,7 +464,7 @@ lazy val enumeratumScalacheck = crossProject(JSPlatform, JVMPlatform, NativePlat | |
version := Versions.Core.head, | ||
crossScalaVersions := scalaVersionsAll, | ||
libraryDependencies ++= { | ||
val (ver, mod, ver2) = ("1.18.0", "scalacheck-1-18", "3.2.19.0") | ||
val (ver, mod, ver2) = ("1.18.1", "scalacheck-1-18", "3.2.19.0") | ||
|
||
Seq( | ||
"org.scalacheck" %%% "scalacheck" % ver, | ||
|
@@ -685,7 +688,7 @@ lazy val compilerSettings = Seq( | |
|
||
val base = { | ||
if (scalaBinaryVersion.value == "3") { | ||
minimal :+ "-deprecation" | ||
minimal :+ "-Wconf:cat=deprecation:s" | ||
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. Curious why this was needed? 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.
and a few more identical errors |
||
} else { | ||
minimal ++ Seq( | ||
// "-Ywarn-adapted-args", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ object Cats { | |
/** Builds an `Eq` instance which differentiates all enum values as it's based on universal | ||
* equals. | ||
*/ | ||
def eqForEnum[A <: ValueEnumEntry[_]]: Eq[A] = Eq.fromUniversalEquals[A] | ||
def eqForEnum[A <: ValueEnumEntry[?]]: Eq[A] = Eq.fromUniversalEquals[A] | ||
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. Was this needed? |
||
|
||
/** Builds an `Eq` instance which acts accordingly to the given `Eq` on the value type. Allows to | ||
* implement different behaviour than [[eqForEnum]], for example grouping several enum values in | ||
|
@@ -17,7 +17,7 @@ object Cats { | |
|
||
/** Builds a `Show` instance based on `toString`. | ||
*/ | ||
def showForEnum[A <: ValueEnumEntry[_]]: Show[A] = Show.fromToString[A] | ||
def showForEnum[A <: ValueEnumEntry[?]]: Show[A] = Show.fromToString[A] | ||
|
||
/** Builds a `Show` instance from the given `Show` on the value type. | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ trait EnumEntry { | |
*/ | ||
def entryName: String = stableEntryName | ||
|
||
private[this] lazy val stableEntryName: String = toString | ||
private lazy val stableEntryName: String = toString | ||
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. Was this (and below) removals of 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. the scala 3 build fails without removing these (deprecated feature) |
||
|
||
} | ||
|
||
|
@@ -62,39 +62,39 @@ object EnumEntry { | |
trait CapitalSnakecase extends EnumEntry { | ||
override def entryName: String = stableEntryName | ||
|
||
private[this] lazy val stableEntryName: String = camel2WordArray(super.entryName).mkString("_") | ||
private lazy val stableEntryName: String = camel2WordArray(super.entryName).mkString("_") | ||
} | ||
|
||
/** Stackable trait to convert the entryName to Capital-Hyphen-Case. | ||
*/ | ||
trait CapitalHyphencase extends EnumEntry { | ||
override def entryName: String = stableEntryName | ||
|
||
private[this] lazy val stableEntryName: String = camel2WordArray(super.entryName).mkString("-") | ||
private lazy val stableEntryName: String = camel2WordArray(super.entryName).mkString("-") | ||
} | ||
|
||
/** Stackable trait to convert the entryName to Capital.Dot.Case. | ||
*/ | ||
trait CapitalDotcase extends EnumEntry { | ||
override def entryName: String = stableEntryName | ||
|
||
private[this] lazy val stableEntryName: String = camel2WordArray(super.entryName).mkString(".") | ||
private lazy val stableEntryName: String = camel2WordArray(super.entryName).mkString(".") | ||
} | ||
|
||
/** Stackable trait to convert the entryName to Capital Words. | ||
*/ | ||
trait CapitalWords extends EnumEntry { | ||
override def entryName: String = stableEntryName | ||
|
||
private[this] lazy val stableEntryName: String = camel2WordArray(super.entryName).mkString(" ") | ||
private lazy val stableEntryName: String = camel2WordArray(super.entryName).mkString(" ") | ||
} | ||
|
||
/** Stackable trait to convert the entryName to CamelCase. | ||
*/ | ||
trait Camelcase extends EnumEntry { | ||
override def entryName: String = stableEntryName | ||
|
||
private[this] lazy val stableEntryName: String = | ||
private lazy val stableEntryName: String = | ||
camel2WordArray(super.entryName).map(s => capitalise(s.toLowerCase)).mkString | ||
} | ||
|
||
|
@@ -103,23 +103,23 @@ object EnumEntry { | |
trait Uppercase extends EnumEntry { | ||
override def entryName: String = stableEntryName | ||
|
||
private[this] lazy val stableEntryName: String = super.entryName.toUpperCase | ||
private lazy val stableEntryName: String = super.entryName.toUpperCase | ||
} | ||
|
||
/** Stackable trait to convert the entryName to lowercase. | ||
*/ | ||
trait Lowercase extends EnumEntry { | ||
override def entryName: String = stableEntryName | ||
|
||
private[this] lazy val stableEntryName: String = super.entryName.toLowerCase | ||
private lazy val stableEntryName: String = super.entryName.toLowerCase | ||
} | ||
|
||
/** Stackable trait to uncapitalise the first letter of the entryName. | ||
*/ | ||
trait Uncapitalised extends EnumEntry { | ||
override def entryName: String = stableEntryName | ||
|
||
private[this] lazy val stableEntryName: String = uncapitalise(super.entryName) | ||
private lazy val stableEntryName: String = uncapitalise(super.entryName) | ||
} | ||
|
||
/** Stackable trait to convert the entryName to snake_case. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import play.api.data.{FormError, Mapping, Forms => PlayForms} | |
*/ | ||
object Forms extends FormsCompat { | ||
|
||
protected[this] def formatter[ValueType, EntryType <: ValueEnumEntry[ | ||
protected def formatter[ValueType, EntryType <: ValueEnumEntry[ | ||
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. ? |
||
ValueType | ||
], EnumType <: ValueEnum[ValueType, EntryType]]( | ||
baseFormatter: Formatter[ValueType] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
scala-2.13 |
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.
Curious if there's a way to make this additional dependency
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.
Unfortunately I think only the consumer of the library knows if the mixed mode macro is being used, from here, sbt only knows that it's a scala3 build.
I believe we could mark this as
Provided
too, but then all consumers would need to explicitly provide it. Marking it provided here means I also need to add it as Provided incore
. It would only need to be added as a normal/runtime dep if the project was using the mixed mode because I think this is only needed for the scala 2 portion of the build.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.
@lloydmeta let me know if you have a preference here.