-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Symbol.allMembers to reflection API #13391
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
Conversation
@@ -3652,6 +3652,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => | |||
/** All members directly declared in the class */ | |||
def declarations: List[Symbol] | |||
|
|||
/** All members declared or inherited */ | |||
def allMembers: List[Symbol] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like in the documentation of Type#allMembers, we should mention that this can be slow to compute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need then to update other methods documentation that use in their implementation Type#allMembers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better would be to fix these methods to not call allMembers :) Instead, we should be able to use memberDenots in most cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make this an iterator. We already do this for allOverriddenSymbols
which has a similar complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should also be marked as @experimental
Part of #13371 |
5c66118
to
a2bc3e3
Compare
@@ -2603,6 +2603,13 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler | |||
def declarations: List[Symbol] = | |||
self.typeRef.info.decls.toList | |||
|
|||
def allMembers: List[Symbol] = | |||
lookupPrefix.allMembers.iterator.map(_.symbol).collect { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the test I added, the order of the members is not deterministic.
For now, we'll stick to internal compiler API in terms of this method. |
No description provided.