Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnu-liguobin committed Jun 23, 2022
1 parent 64e48bf commit 2aa53ca
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions smt-common/src/main/scala/org/bitlap/common/TransformerMacro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -202,21 +202,17 @@ class TransformerMacro(override val c: whitebox.Context) extends AbstractMacroPr
): Tree = {
val fromFieldTerm = q"$fromTermName.${TermName(realFromFieldName)}"
val fromClassName = resolveClassTypeName[From]

if (fromFieldOpt.isEmpty && !customDefaultValueMapping.keySet.contains(toField.fieldName)) {
c.abort(
c.enclosingPosition,
s"The value `$realFromFieldName` is not a member of `$fromClassName`!" +
s"\nPlease consider using `setDefaultValue` method!"
)
return fromFieldTerm
}

fromFieldOpt match {
case Some(fromField) if !(fromField.fieldType weak_<:< toField.fieldType) =>
tryForWrapType(fromFieldTerm, fromField, toField)
case Some(fromField) if fromField.fieldType weak_<:< toField.fieldType =>
q"${TermName(toField.fieldName)} = $fromFieldTerm"
case None if !customDefaultValueMapping.keySet.contains(toField.fieldName) =>
c.abort(
c.enclosingPosition,
s"The value `$realFromFieldName` is not a member of `$fromClassName`!" +
s"\nPlease consider using `setDefaultValue` method!"
)
case _ =>
val value = q"""${TermName(builderDefaultValuePrefix$ + toField.fieldName)}"""
q"${TermName(toField.fieldName)} = $value"
Expand Down

0 comments on commit 2aa53ca

Please sign in to comment.