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

Do not look for implicits when into.transform set up flags #413

Closed
MateuszKubuszok opened this issue Oct 19, 2023 · 0 comments · Fixed by #412
Closed

Do not look for implicits when into.transform set up flags #413

MateuszKubuszok opened this issue Oct 19, 2023 · 0 comments · Fixed by #412
Labels
enhancement relatively easy but not small Task with requires some knowlege and writing more code, but not the intimate knoledge about macros

Comments

@MateuszKubuszok
Copy link
Member

One of the (unanswered) questions from Gitter mentioned this code:

implicit val childBtoChildBC: Transformer[ChildB, ChildBC] = (childb: ChildB) => {
      childb.into[ChildBC]
        .enableBeanSetters
        .enableBeanGetters
        .transform
    }

While the question was about forward reference extends over definition of value (self reference in the implicit -> cyclical dependency) it macro would not find implicit itself if it skip on looking for an implicit. For our users it seems intuitive to assume that if we put anything between .into and .transform, then implicit will not be looked for. In 0.8.0 we disabled looking for implicit it override is set (withField*, withCoproduct*), but not for flags (enable*, disable*).

It was for a good reason: we are using implicit TransformerConfiguration to share several flags. Some instance of it is always present. If we disable looking for implicit if any flag is set:

  • settings any flag with implicit would disable all implicit lookups which probably isn't what people would look for
  • if we set a flag by implicit and disable it locally, implicit would be looked up again - even though we just defined a customization

So probably the most intuitive approach would be to disable implicit lookup if any flag is set for instance but not if flags are set globally (via implicit) - if user want to use the implicit Transformer they would not set any customization themselves, if they want to force inline derivation they can repeat any flag (this should be documented).

@MateuszKubuszok MateuszKubuszok added the relatively easy but not small Task with requires some knowlege and writing more code, but not the intimate knoledge about macros label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement relatively easy but not small Task with requires some knowlege and writing more code, but not the intimate knoledge about macros
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant