Resolve a longstanding issue with resolving Transformers in macros & more Transformer AST rewrites to get rid of unnecessary runtime instances
#21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Expr.summonandImplicits.search) was failing and a fallback toscala.compiletime.summonInlinewas neededA solution to this issue was to create a macro that creates the typeclass instance itself not a macro that only does the underlying transformation.
Eg.
This fix allowed me to greatly simplify logic of
Transformernormalization, which can now be done straight after getting our hands on an instance of a transformer instead of going through the whole tree to transform some specific nodes after (summonInlineexpands some time after the initial inlining?)Examples:
person.to[Person2]now expands to:Note how
insideexpands to aSome(...), in the previous version this call would allocate two more instances ofTransformerand then do the transformation, now it does the transformation without any extra allocations.It also rewrites collection-to-collection transformation to
Just as in the
Some(...)example, no intermediate transformers are needed anymore!I also plan to special case invocations of
todo rewrite the AST to contain the transformation lifted from the supplied transformer so in some cases the library will be able to get rid of an additional transformer instance.