Skip to content

Commit a906bb2

Browse files
authored
Merge pull request #569 from plokhotnyuk/fix-to-work-with-explicit-nulls
Fix error with "-Yexplicit-nulls" compiler option
2 parents 079b5fd + 3abfe49 commit a906bb2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

core/src/main/scala/magnolia1/impl.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,17 @@ object CaseClassDerivation:
111111
val label = constValue[l].asInstanceOf[String]
112112
val tc = new SerializableFunction0[Typeclass[p]]:
113113
override def apply(): Typeclass[p] = summonInline[Typeclass[p]]
114-
val evaluator: () => Any = defaults(label).orNull
115114
val d =
116-
if (evaluator ne null) {
117-
new SerializableFunction0[Option[p]]:
118-
override def apply(): Option[p] =
119-
val v = evaluator()
120-
if (v.isInstanceOf[p]) Some(v.asInstanceOf[p])
121-
else None
122-
} else {
123-
new SerializableFunction0[Option[p]]:
124-
override def apply(): Option[p] = None
115+
defaults(label) match {
116+
case Some(evaluator) =>
117+
new SerializableFunction0[Option[p]]:
118+
override def apply(): Option[p] =
119+
val v = evaluator()
120+
if (v.isInstanceOf[p]) Some(v.asInstanceOf[p])
121+
else None
122+
case _ =>
123+
new SerializableFunction0[Option[p]]:
124+
override def apply(): Option[p] = None
125125
}
126126
paramFromMaps[Typeclass, A, p](
127127
label,

0 commit comments

Comments
 (0)