Skip to content

Commit

Permalink
EnumExtender: Support sealed classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
LlamaLad7 committed Mar 28, 2023
1 parent 6cc4a93 commit 11edbe4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/com/chocohead/mm/EnumExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ static Consumer<ClassNode> makeEnumExtender(EnumAdder builder) {
InsnList arrayFilling = new InsnList();

for (EnumAddition addition : builder.getAdditions()) {
String additionType = addition.isEnumSubclass() ? anonymousClassFactory.get() : node.name;
if (addition.isEnumSubclass() && node.permittedSubclasses != null) {
node.permittedSubclasses.add(additionType);
}
node.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC + Opcodes.ACC_ENUM, addition.name, 'L' + node.name + ';', null, null);

LabelNode stuffStart;
Expand All @@ -193,7 +197,6 @@ static Consumer<ClassNode> makeEnumExtender(EnumAdder builder) {
fieldSetting.add(stuffStart);
} else stuffStart = null;

String additionType = addition.isEnumSubclass() ? anonymousClassFactory.get() : node.name;
fieldSetting.add(new TypeInsnNode(Opcodes.NEW, additionType));
fieldSetting.add(new InsnNode(Opcodes.DUP));

Expand Down

0 comments on commit 11edbe4

Please sign in to comment.