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

Macros don't warn against visibility issues #6003

Closed
scabug opened this issue Jun 28, 2012 · 2 comments
Closed

Macros don't warn against visibility issues #6003

scabug opened this issue Jun 28, 2012 · 2 comments
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Jun 28, 2012

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:

  1. There was no complain at trace that traceImpl was private, or vice versa.

  2. 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 class Macros$ 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.

@scabug
Copy link
Author

scabug commented Jun 28, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6003?orig=1
Reporter: @dcsobral
Affected Versions: 2.10.0-M4

@scabug
Copy link
Author

scabug commented Jul 10, 2013

@adriaanm said:
Unassigning as milestone deadline was reached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant