You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was playing with this macro and this example, and wondered about the wildcard import. That makes the macro definition itself visible, which might not be desirable. At that point, I wondered what would happen if that definition was made private. The results I got were:
There was no complain at trace that traceImpl was private, or vice versa.
When I tried to use trace, I got this:
scala> trace(2+ x)
<console>:12:error: exception during macro expansion:
java.lang.IllegalAccessException:Class scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroRuntime$2 can not access a member of classMacros$with modifiers "private"
Now, I don't see any situation where a private macro definition might make sense. If I understand it correctly, it will always be the compiler calling them, which makes it important not only that they are static, as is already complained about, but that they are public.
In which case, an error message is in order.
As a side note, the fact that I can't envision any situation where a different visibility makes sense is making me unease. I sense that there's some design issue there I can't quite put a finger on.
The text was updated successfully, but these errors were encountered:
I was playing with this macro and this example, and wondered about the wildcard import. That makes the macro definition itself visible, which might not be desirable. At that point, I wondered what would happen if that definition was made private. The results I got were:
There was no complain at
trace
thattraceImpl
was private, or vice versa.When I tried to use
trace
, I got this:Now, I don't see any situation where a private macro definition might make sense. If I understand it correctly, it will always be the compiler calling them, which makes it important not only that they are static, as is already complained about, but that they are public.
In which case, an error message is in order.
As a side note, the fact that I can't envision any situation where a different visibility makes sense is making me unease. I sense that there's some design issue there I can't quite put a finger on.
The text was updated successfully, but these errors were encountered: