Skip to content

Do not expose ClassInfo in memberType in reflect API #22402

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 1 commit into from

Conversation

jchyb
Copy link
Contributor

@jchyb jchyb commented Jan 17, 2025

fixes #22395
fixes #13319
fixes #15159

The asSeenFrom method, used in TypeRepr.memberType sometimes can return ClassInfo instances, which we do not expose in the reflect API. This is either caused by nonsensical calls (calls with symbols unrelated to the type), or as in case of issue #22395, correct calls on nested classes.

Since ClassInfo gives us precise type prefix and symbol, we transform that ClassInfo into a TypeRef (which is how types pointing to classes are usually represented in the reflect API).

Previously (in #15161) there were attempts to completely limit calling memberType to the direct members of the type (to avoid the nonsensical calls), however that causes major regressions in both the compilation tests, and (in my opinion) functionality (as explained in the comment). So instead we check if the passed symbol if any owner of the passed symbol is a member of the typeRepr (basically, we allow obtaining the types of a nested members). With the above fix, this check is not strictly necessary, but I think it might help avoid confusion about how memberType is supposed to be used.

@jchyb
Copy link
Contributor Author

jchyb commented Feb 18, 2025

Needs #22448 to be merged first, so will be reopened after that is merged

@jchyb jchyb closed this Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant