Compile-time conditional implicit (if fails, continue implicit search) #15895
Unanswered
adamw
asked this question in
Metaprogramming
Replies: 1 comment 3 replies
-
Not completely sure what you are trying to do. Can you give an example of what you want to happen and what happens currently? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to define an implicit value, but only if a compile-time condition is met, so that the implicit search continues (using lower-precedence values) if the condition is false?
This would be trivial if not for the second part: the inline/macro can simply report a compile-time error if the condition is false and be done with it. However, I'd like to define a special-case implicit for which a compile-time check needs to be done.
I've tried with transparent implicits, sth like:
However, despite being
transparent
, and despite returning the right sub-type from the macro implementation, theYes
implicit is never found.Even a simple
implicitly[MyCondition.Yes[T]]]
fails, so I guess the type of transparent implicits isn't refined before implicit search resolution?But maybe there's another way to define a conditional implicit as described above?
Beta Was this translation helpful? Give feedback.
All reactions