Skip to content

Commit

Permalink
Merge pull request #130 from eed3si9n/wip/more-classtag
Browse files Browse the repository at this point in the history
more ClassTag
  • Loading branch information
eed3si9n committed Oct 19, 2022
2 parents 19361c5 + b872fe9 commit 496a11c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ val scala212 = "2.12.15"
val scala213 = "2.13.8"
val scala3 = "3.1.0"

ThisBuild / version := "0.11.0-SNAPSHOT"
ThisBuild / version := "0.12.0-SNAPSHOT"
ThisBuild / scalaVersion := scala212
lazy val allScalaVersions = Seq(scala212, scala213, scala3)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ trait FlatUnionFormats {
private[this] type JF[A] = JsonFormat[A] // simple alias for reduced verbosity

[#/** *BEWARE*: [# A1#] must be a concrete leaf type, and not an interface. */
def flatUnionFormat1[U, [#A1 :JF: Manifest#]]: JF[U] =
def flatUnionFormat1[U, [#A1 :JF: ClassTag#]]: JF[U] =
flatUnionFormat1[U, [#A1#]]("type")#
]
[#/** *BEWARE*: [# A1#] must be a concrete leaf type, and not an interface. */
def flatUnionFormat1[U, [#A1 :JF: Manifest#]](typeFieldName: String): JF[U] = new JF[U] {
def flatUnionFormat1[U, [#A1 :JF: ClassTag#]](typeFieldName: String): JF[U] = new JF[U] {
[#lazy val a1Format = implicitly[JF[A1]]#
]

[#lazy val a1Name = className(implicitly[Manifest[A1]].runtimeClass)#
[#lazy val a1Name = className(implicitly[ClassTag[A1]].runtimeClass)#
]

def write[J](u: U, builder: Builder[J]): Unit = {
Expand All @@ -23,7 +23,7 @@ trait FlatUnionFormats {
builder.writeString(className(u.getClass))
builder.endPreObject()
u match {
[# case x if implicitly[Manifest[A1]].runtimeClass == x.getClass => a1Format.write(x.asInstanceOf[A1], builder)#
[# case x if implicitly[ClassTag[A1]].runtimeClass == x.getClass => a1Format.write(x.asInstanceOf[A1], builder)#
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.6.1
sbt.version=1.7.2

0 comments on commit 496a11c

Please sign in to comment.