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

Exposing the flags method in the public API for symbols #6785

Closed
scabug opened this issue Dec 7, 2012 · 6 comments
Closed

Exposing the flags method in the public API for symbols #6785

scabug opened this issue Dec 7, 2012 · 6 comments

Comments

@scabug
Copy link

scabug commented Dec 7, 2012

It would be convenient to be able to access a symbol's flags directly. For example, if we want to implement a trait's methods in a macro, but don't have access to a tree for the trait, we currently have to iterate through the trait type's declarations and manually create Modifiers for each by reconstructing the flags from the method symbol's isPrivate, etc. methods.

See this Stack Overflow question for a more detailed discussion of the issue.

@scabug
Copy link
Author

scabug commented Dec 7, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6785?orig=1
Reporter: Travis Brown (travisbrown)
Affected Versions: 2.10.0-RC3

@scabug
Copy link
Author

scabug commented Dec 7, 2012

@paulp said (edited on Dec 7, 2012 11:58:37 PM UTC):
It's a (very) conscious decision not to expose flags. You can easily obtain it through the side door, {code}sym.asInstanceOf[scala.tools.nsc.Global#Symbol].flags{code}
Examples of things which you cannot do for want of access to flags do represent bugs or possible improvements, but exposing flags is not the only way, nor the most likely way, to remedy them.

@scabug
Copy link
Author

scabug commented Dec 13, 2012

@adriaanm said:
(Pushing reflection bugs to 2.11 to aid scheduling -- as it's experimental in 2.10.x, it shouldn't influence 2.10's schedule. They may be fixed earlier, of course.)

@scabug
Copy link
Author

scabug commented Jul 10, 2013

@adriaanm said:
Unassigning as milestone deadline was reached.

@scabug
Copy link
Author

scabug commented Feb 1, 2014

@xeno-by said (edited on Feb 1, 2014 1:49:44 AM UTC):
I was very close to fixing this issue in scala/scala#3452, but in the end I decided against it, because just flags are unlikely to be enough.

When creating flags based on someone else's flags it is oftentimes necessary to negate some bits or to only obtain a subset of those bits - something that's currently not available in the API, and exposing all that stuff on the verge of #6267 seems a bit too much.

If you feel that you need flags in the public API, please speak up - I will be glad to re-evaluate the "won't fix" given strong evidence.

@scabug
Copy link
Author

scabug commented Feb 15, 2014

@xeno-by said (edited on Feb 15, 2014 12:49:50 AM UTC):
scala/scala#3452

#6785 exposes Symbol.flags, setFlag and resetFlag

My first feeling was not to expose Symbol.flags, because that would
inevitably lead to exposing more methods on FlagSet. However we do need
flag manipulation in async, which is representative of advanced macros,
so I'm caving in.

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

No branches or pull requests

2 participants