From 70b0645bc989ff4ad2d1a1cbc464816e1f0b2c6d Mon Sep 17 00:00:00 2001 From: LlamaLad7 Date: Mon, 20 Mar 2023 23:20:28 +0000 Subject: [PATCH] EnumExtender: Support sealed classes. --- src/com/chocohead/mm/EnumExtender.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/chocohead/mm/EnumExtender.java b/src/com/chocohead/mm/EnumExtender.java index 783af93..d014625 100644 --- a/src/com/chocohead/mm/EnumExtender.java +++ b/src/com/chocohead/mm/EnumExtender.java @@ -176,6 +176,10 @@ static Consumer 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; @@ -193,7 +197,6 @@ static Consumer 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));