Skip to content

Commit

Permalink
Fix crash when a mixin missing a target has an inner class
Browse files Browse the repository at this point in the history
Doesn't crash-crash, but will refuse to apply the mixin on any non-missing targets
  • Loading branch information
Chocohead committed Dec 16, 2024
1 parent cfe821a commit b283b76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,13 @@ Set<String> getSyntheticInnerClasses() {
return Collections.<String>unmodifiableSet(this.getState().getSyntheticInnerClasses());
}

/**
* True if there are any user-defined inner classes for this mixin
*/
boolean hasInnerClasses() {
return !this.getState().getInnerClasses().isEmpty();
}

/**
* Get the user-defined inner classes for this mixin
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,12 @@ final MixinPreProcessorStandard prepare(Extensions extensions) {
}

protected void prepareInnerClasses(Extensions extensions) {
InnerClassGenerator icg = extensions.<InnerClassGenerator>getGenerator(InnerClassGenerator.class);
for (String targetClassName : this.mixin.getDeclaredTargetClasses()) {
ClassInfo targetClassInfo = ClassInfo.forName(targetClassName);
for (String innerClass : this.mixin.getInnerClasses()) {
icg.registerInnerClass(this.mixin, targetClassInfo, innerClass);
if (this.mixin.hasInnerClasses()) {
InnerClassGenerator icg = extensions.<InnerClassGenerator>getGenerator(InnerClassGenerator.class);
for (ClassInfo targetClassInfo : this.mixin.getTargets()) {
for (String innerClass : this.mixin.getInnerClasses()) {
icg.registerInnerClass(this.mixin, targetClassInfo, innerClass);
}
}
}
}
Expand Down

0 comments on commit b283b76

Please sign in to comment.