Plugin which summons an implicit #20406
Unanswered
adamw
asked this question in
Compiler internals Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I'm trying to write a compiler plugin which would try summoning an implicit at certain applications (
Apply
trees). After many trial&errors I did findtyper.inferImplicit
, however this seems to work only in a limited number of cases. Here's the plugin code that I have (simplified):This works if the implicit is defined as a top-level value:
At the application point
s.length()
looking up theTest
implicit is successful.However, all other cases fail, e.g.:
here, at the application of
s.length()
no implicit value is found; same if the instance is provided via ausing
clause of the method declaration, or as a context parameter.I do realise that probably the "proper" implicit scope is only built out during
typer
, and for plugins the tree transformations don't re-enrich the scope as the tree is transformed. Though, maybe there is a way to somehow construct the proper implicit search context in my plugin?Or does this mean that post-typer, there's no way to inject any code that would summon an implicit?
Beta Was this translation helpful? Give feedback.
All reactions