Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

pikinier20
Copy link
Contributor

No description provided.

@@ -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]
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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

Copy link
Contributor

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.

Copy link
Contributor

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

@nicolasstucki
Copy link
Contributor

Part of #13371

@@ -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 {
Copy link
Contributor

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.

@pikinier20
Copy link
Contributor Author

For now, we'll stick to internal compiler API in terms of this method.

@pikinier20 pikinier20 closed this Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants