Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extra fields in Patcher classes that don't exist in original #98

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ trait PatcherMacros {
val fnObj = c.internal.reificationSupport.freshTermName("obj$")
val fnPatch = c.internal.reificationSupport.freshTermName("patch$")

val targetMapping = patchParams.toSeq.map { pParam =>
tParamsByName.get(pParam.name) match {
case Some(tParam) if pParam.returnType <:< tParam.returnType =>
Right(q"$fnPatch.${pParam.name}")
case Some(tParam) =>
transformOptionalValue(fnPatch, pParam, tParam, fnObj)
case None =>
Left(s"Field named '${pParam.name}' not found in target patching type $T!")
}
val matchingParams = patchParams.toSeq flatMap { pParam =>
tParamsByName.get(pParam.name).map(_ -> pParam)
}

val targetMapping = matchingParams.map {
case (tParam, pParam) if pParam.returnType <:< tParam.returnType =>
Right(q"$fnPatch.${pParam.name}")
case (tParam, pParam) =>
transformOptionalValue(fnPatch, pParam, tParam, fnObj)
}

if (targetMapping.exists(_.isLeft)) {
Expand Down