Skip to content

Commit a6aff29

Browse files
committed
more robust macro implementation, test for edge case
fixes #265
1 parent 653eeac commit a6aff29

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

gremlin-scala/src/test/scala/gremlin/scala/marshallable/MarshallableSpec.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ class MarshallableSpec extends WordSpec with Matchers {
351351
results shouldBe Set(cc1, cc2)
352352
}
353353

354+
case class EmptyCC()
355+
"handle case class without elements" in new Fixture {
356+
val m = implicitly[Marshallable[EmptyCC]]
357+
}
358+
354359
trait Fixture {
355360
val graph = TinkerGraph.open.asScala
356361
}

macros/src/main/scala/gremlin/scala/Marshallable.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@ object Marshallable {
196196
$label,
197197
_root_.scala.collection.immutable.List(..$fromCCParams)
198198
.flatten
199-
.filter(kv => _root_.scala.Option(kv._2).isDefined)
199+
.filter { kv =>
200+
kv.isInstanceOf[Product2[_, _]] &&
201+
kv.asInstanceOf[Product2[_, _]]._2 != null
202+
}
200203
)
201204
def toCC(element: _root_.gremlin.scala.Element): $tpe = $companion(..$toCCParams)
202205
}

0 commit comments

Comments
 (0)