fix: inline class constants to fix enum transform (#916)

This commit is contained in:
Skylot
2020-05-03 19:27:54 +01:00
parent f3cd4e38d7
commit 2207cd7b52
3 changed files with 13 additions and 0 deletions
+1
View File
@@ -5,6 +5,7 @@
# IntelliJ Idea files
.idea/
.run/
out/
*.iml
*.ipr
@@ -100,6 +100,12 @@ public class ConstInlineVisitor extends AbstractVisitor {
constArg = InsnArg.wrapArg(constGet);
constArg.setType(ArgType.STRING);
}
} else if (insnType == InsnType.CONST_CLASS) {
if (sVar.isUsedInPhi()) {
return;
}
constArg = InsnArg.wrapArg(insn.copyWithoutResult());
constArg.setType(ArgType.CLASS);
} else {
return;
}
@@ -293,6 +293,12 @@ public class EnumVisitor extends AbstractVisitor {
if (mth == null) {
return null;
}
List<RegisterArg> regs = new ArrayList<>();
co.getRegisterArgs(regs);
if (!regs.isEmpty()) {
cls.addWarnComment("Init of enum " + enumFieldNode.getName() + " can be incorrect");
}
markArgsForSkip(mth);
return new EnumField(enumFieldNode, co);
}