aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Pretty <jon.pretty@propensive.com>2018-06-15 18:42:07 +0100
committerJon Pretty <jon.pretty@propensive.com>2018-06-15 18:42:07 +0100
commit5937e5889be8d0683ba4fd11e78699cf94650eb0 (patch)
tree038bd59c5a86c58edee4bffa5068f6f1dca466f0
parent091788d0ad6f94c91cc20d6074c3403934702325 (diff)
parent707af80e2e7870a990189bdcf66dd8c532143e38 (diff)
downloadmagnolia-5937e5889be8d0683ba4fd11e78699cf94650eb0.tar.gz
magnolia-5937e5889be8d0683ba4fd11e78699cf94650eb0.tar.bz2
magnolia-5937e5889be8d0683ba4fd11e78699cf94650eb0.zip
Merge branch 'master' of github.com:propensive/magnolia
-rw-r--r--build.sbt21
-rw-r--r--core/shared/src/main/scala/magnolia.scala13
2 files changed, 21 insertions, 13 deletions
diff --git a/build.sbt b/build.sbt
index 0239960..903933f 100644
--- a/build.sbt
+++ b/build.sbt
@@ -12,10 +12,10 @@ lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
scalaVersion := crossScalaVersions.value.head
)
.jvmSettings(
- crossScalaVersions := "2.12.4" :: "2.13.0-M3" :: "2.11.12" :: Nil
+ crossScalaVersions := "2.12.4" :: "2.13.0-M4" :: "2.11.12" :: Nil
)
.jsSettings(
- crossScalaVersions := "2.12.4" :: "2.11.12" :: Nil
+ crossScalaVersions := "2.12.4" :: "2.13.0-M4" :: "2.11.12" :: Nil
)
.nativeSettings(
crossScalaVersions := "2.11.12" :: Nil
@@ -86,14 +86,23 @@ lazy val buildSettings = Seq(
"-deprecation",
"-feature",
"-Xfuture",
- "-Xexperimental",
"-Ywarn-value-discard",
"-Ywarn-dead-code",
- "-Ywarn-nullary-unit",
"-Ywarn-numeric-widen",
- "-Ywarn-inaccessible",
- "-Ywarn-adapted-args"
),
+ scalacOptions ++= {
+ CrossVersion.partialVersion(scalaVersion.value) match {
+ case Some((2, v)) if v <= 12 =>
+ Seq(
+ "-Xexperimental",
+ "-Ywarn-nullary-unit",
+ "-Ywarn-inaccessible",
+ "-Ywarn-adapted-args"
+ )
+ case _ =>
+ Nil
+ }
+ },
scmInfo := Some(
ScmInfo(url("https://github.com/propensive/magnolia"),
"scm:git:git@github.com:propensive/magnolia.git")
diff --git a/core/shared/src/main/scala/magnolia.scala b/core/shared/src/main/scala/magnolia.scala
index dd1e0e8..c2dbf0a 100644
--- a/core/shared/src/main/scala/magnolia.scala
+++ b/core/shared/src/main/scala/magnolia.scala
@@ -15,7 +15,6 @@
package magnolia
import scala.annotation.compileTimeOnly
-import scala.collection.breakOut
import scala.collection.mutable
import scala.language.existentials
import scala.language.higherKinds
@@ -102,7 +101,7 @@ object Magnolia {
def knownSubclasses(sym: ClassSymbol): List[Symbol] = {
val children = sym.knownDirectSubclasses.toList
val (abstractTypes, concreteTypes) = children.partition(_.isAbstract)
-
+
abstractTypes.map(_.asClass).flatMap(knownSubclasses(_)) ::: concreteTypes
}
@@ -166,7 +165,7 @@ object Magnolia {
def directInferImplicit(genericType: Type, typeConstructor: Type): Option[Tree] = {
val genericTypeName = genericType.typeSymbol.name.decodedName.toString.toLowerCase
- val assignedName = TermName(c.freshName(s"${genericTypeName}Typeclass"))
+ val assignedName = TermName(c.freshName(s"${genericTypeName}Typeclass")).encodedName.toTermName
val typeSymbol = genericType.typeSymbol
val classType = if (typeSymbol.isClass) Some(typeSymbol.asClass) else None
val isCaseClass = classType.exists(_.isCaseClass)
@@ -312,7 +311,7 @@ object Magnolia {
..$assignments
$typeNameDef
-
+
${c.prefix}.combine($magnoliaPkg.Magnolia.caseClass[$typeConstructor, $genericType](
$typeName,
false,
@@ -374,11 +373,11 @@ object Magnolia {
Some(q"""{
val $subtypesVal: $scalaPkg.Array[$magnoliaPkg.Subtype[$typeConstructor, $genericType]] =
new $scalaPkg.Array(${assignments.size})
-
+
..$assignments
$typeNameDef
-
+
${c.prefix}.dispatch(new $magnoliaPkg.SealedTrait(
$typeName,
$subtypesVal: $scalaPkg.Array[$magnoliaPkg.Subtype[$typeConstructor, $genericType]],
@@ -517,7 +516,7 @@ private[magnolia] object CompileTimeState {
(frames.drop(1), frames).zipped.collect {
case (Frame(path, tp1, _), Frame(_, tp2, _))
if !(tp1 =:= tp2) => path
- } (breakOut)
+ }.toList
override def toString: String =
frames.mkString("magnolia stack:\n", "\n", "\n")