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

Fixes and improvements for retrieving IMixinInfo from ClassInfo #119

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

comp500
Copy link

@comp500 comp500 commented Aug 14, 2023

In MixinInfo#postApply, the MixinInfo reference is being added to the ClassInfo of the mixin itself, rather than the classes the mixin is applied to. This means that Mixins.getMixinsForClass only returns MixinInfo on mixin classes themselves, not their target classes, and ClassInfo#getAppliedMixins() is empty for target classes.

The following 3 changes are made in this PR:

  • Fix the behaviour to resolve the ClassInfo of the target class and add the MixinInfo to that.
  • Allow external code to query the list of mixins that target a class, including mixins that were not applied, by exposing getMixins as a public method; this method wasn't used internally but exposing it allows external error handlers greater visibility of mixins targeting a class.
  • Expose ClassInfo.mixin with getMixinInfo to allow external code to retrieve mixin metadata from a class. This supersedes the need for some other methods like isMixin and isLoadable, but these are kept for compatibility.

(upstream equivalent PR: SpongePowered#529)

In MixinInfo#postApply, the MixinInfo reference was being added to the
ClassInfo of the mixin itself, rather than the classes the mixin is
applied to. This meant that Mixins.getMixinsForClass would only return
MixinInfo on mixin classes themselves, not their target classes, and
ClassInfo#getAppliedMixins() was empty for target classes.
This change fixes the behaviour to resolve the ClassInfo of the target
class and add the MixinInfo to that.
Allow external code to query the list of mixins that target a class,
including mixins that were not applied, by exposing getMixins; this
method wasn't used internally but exposing it allows external error
handlers greater visibility of mixins targeting a class.

ClassInfo.mixin is also exposed with getMixinInfo to allow external
code to retrieve mixin metadata from a class. This supersedes the need
for some other methods like isMixin and isLoadable, but these are kept
for compatibility.
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.

1 participant