Skip to content

Commit

Permalink
Fix of evolution-gaming#18 by enforcing the type information complete…
Browse files Browse the repository at this point in the history
…ness and availability of annotations
  • Loading branch information
plokhotnyuk committed Mar 18, 2018
1 parent 18c519f commit 24b01aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ object Serializer {
if (!tpe.typeSymbol.asClass.isCaseClass) c.error(c.enclosingPosition, s"$tpe must be a case class.")

val annotations = tpe.members.collect {
case m: TermSymbol if m.annotations.nonEmpty => m.getter -> m.annotations.map(_.toString).toSet
case m: TermSymbol if {
m.info // to enforce the type information completeness and availability of annotations
m.annotations.nonEmpty
} => m.getter -> m.annotations.map(_.toString).toSet
}.toMap

def notTransient(m: MethodSymbol) = !annotations.get(m).exists(_.contains("transient"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,10 @@ class SerializerMacroSpec extends WordSpec with Matchers {
}

"don't serialize and deserialize field is annotated by transient or just is not defined in constructor" in {
case class Transient(r: String, @transient t: String = "a") {
val ignored: String = "i" + r
}
val transientSerializer = Serializer.make[Transient]

case class Required(s: String)

val transientSerializer = Serializer.make[Transient]
val requiredSerializer = Serializer.make[Required]
verifyFromTo(transientSerializer, Transient("VVV"), requiredSerializer, Required("VVV"))
verifyFromTo(requiredSerializer, Required("VVV"), transientSerializer, Transient("VVV"))
Expand Down Expand Up @@ -403,3 +400,7 @@ class SerializerMacroSpec extends WordSpec with Matchers {
out.getBuffer
}
}

case class Transient(r: String, @transient t: String = "a") {
val ignored: String = "i" + r
}

0 comments on commit 24b01aa

Please sign in to comment.