未验证 提交 381405ea 编写于 作者: S Skylot

fix: always use deep resolve for fields and methods (#1357)

上级 ae5c0039
...@@ -172,7 +172,7 @@ public class InsnGen { ...@@ -172,7 +172,7 @@ public class InsnGen {
private void instanceField(ICodeWriter code, FieldInfo field, InsnArg arg) throws CodegenException { private void instanceField(ICodeWriter code, FieldInfo field, InsnArg arg) throws CodegenException {
ClassNode pCls = mth.getParentClass(); ClassNode pCls = mth.getParentClass();
FieldNode fieldNode = pCls.root().deepResolveField(field); FieldNode fieldNode = pCls.root().resolveField(field);
if (fieldNode != null) { if (fieldNode != null) {
FieldReplaceAttr replace = fieldNode.get(AType.FIELD_REPLACE); FieldReplaceAttr replace = fieldNode.get(AType.FIELD_REPLACE);
if (replace != null) { if (replace != null) {
...@@ -210,7 +210,7 @@ public class InsnGen { ...@@ -210,7 +210,7 @@ public class InsnGen {
} }
code.add('.'); code.add('.');
} }
FieldNode fieldNode = clsGen.getClassNode().root().deepResolveField(field); FieldNode fieldNode = clsGen.getClassNode().root().resolveField(field);
if (fieldNode != null) { if (fieldNode != null) {
code.attachAnnotation(fieldNode); code.attachAnnotation(fieldNode);
} }
...@@ -764,7 +764,7 @@ public class InsnGen { ...@@ -764,7 +764,7 @@ public class InsnGen {
return; return;
} }
MethodInfo callMth = insn.getCallMth(); MethodInfo callMth = insn.getCallMth();
MethodNode callMthNode = mth.root().deepResolveMethod(callMth); MethodNode callMthNode = mth.root().resolveMethod(callMth);
int k = 0; int k = 0;
switch (type) { switch (type) {
......
...@@ -378,15 +378,6 @@ public class RootNode { ...@@ -378,15 +378,6 @@ public class RootNode {
@Nullable @Nullable
public MethodNode resolveMethod(@NotNull MethodInfo mth) { public MethodNode resolveMethod(@NotNull MethodInfo mth) {
ClassNode cls = resolveClass(mth.getDeclClass());
if (cls != null) {
return cls.searchMethod(mth);
}
return null;
}
@Nullable
public MethodNode deepResolveMethod(@NotNull MethodInfo mth) {
ClassNode cls = resolveClass(mth.getDeclClass()); ClassNode cls = resolveClass(mth.getDeclClass());
if (cls == null) { if (cls == null) {
return null; return null;
...@@ -430,19 +421,14 @@ public class RootNode { ...@@ -430,19 +421,14 @@ public class RootNode {
@Nullable @Nullable
public FieldNode resolveField(FieldInfo field) { public FieldNode resolveField(FieldInfo field) {
ClassNode cls = resolveClass(field.getDeclClass());
if (cls != null) {
return cls.searchField(field);
}
return null;
}
@Nullable
public FieldNode deepResolveField(@NotNull FieldInfo field) {
ClassNode cls = resolveClass(field.getDeclClass()); ClassNode cls = resolveClass(field.getDeclClass());
if (cls == null) { if (cls == null) {
return null; return null;
} }
FieldNode fieldNode = cls.searchField(field);
if (fieldNode != null) {
return fieldNode;
}
return deepResolveField(cls, field); return deepResolveField(cls, field);
} }
......
...@@ -38,7 +38,7 @@ public class MethodUtils { ...@@ -38,7 +38,7 @@ public class MethodUtils {
@Nullable @Nullable
public IMethodDetails getMethodDetails(MethodInfo callMth) { public IMethodDetails getMethodDetails(MethodInfo callMth) {
MethodNode mthNode = root.deepResolveMethod(callMth); MethodNode mthNode = root.resolveMethod(callMth);
if (mthNode != null) { if (mthNode != null) {
return mthNode; return mthNode;
} }
......
...@@ -244,7 +244,7 @@ public class ClassModifier extends AbstractVisitor { ...@@ -244,7 +244,7 @@ public class ClassModifier extends AbstractVisitor {
return false; return false;
} }
MethodInfo callMth = invokeInsn.getCallMth(); MethodInfo callMth = invokeInsn.getCallMth();
MethodNode wrappedMth = mth.root().deepResolveMethod(callMth); MethodNode wrappedMth = mth.root().resolveMethod(callMth);
if (wrappedMth == null) { if (wrappedMth == null) {
return false; return false;
} }
......
...@@ -106,7 +106,7 @@ public class MarkMethodsForInline extends AbstractVisitor { ...@@ -106,7 +106,7 @@ public class MarkMethodsForInline extends AbstractVisitor {
InsnType insnType = insn.getType(); InsnType insnType = insn.getType();
if (insnType == InsnType.INVOKE) { if (insnType == InsnType.INVOKE) {
InvokeNode invoke = (InvokeNode) insn; InvokeNode invoke = (InvokeNode) insn;
MethodNode callMthNode = mth.root().deepResolveMethod(invoke.getCallMth()); MethodNode callMthNode = mth.root().resolveMethod(invoke.getCallMth());
if (callMthNode != null) { if (callMthNode != null) {
FixAccessModifiers.changeVisibility(callMthNode, newVisFlag); FixAccessModifiers.changeVisibility(callMthNode, newVisFlag);
} }
......
...@@ -96,7 +96,7 @@ public class InsnUtils { ...@@ -96,7 +96,7 @@ public class InsnUtils {
return ((ConstClassNode) insn).getClsType(); return ((ConstClassNode) insn).getClsType();
case SGET: case SGET:
FieldInfo f = (FieldInfo) ((IndexInsnNode) insn).getIndex(); FieldInfo f = (FieldInfo) ((IndexInsnNode) insn).getIndex();
FieldNode fieldNode = root.deepResolveField(f); FieldNode fieldNode = root.resolveField(f);
if (fieldNode == null) { if (fieldNode == null) {
LOG.warn("Field {} not found", f); LOG.warn("Field {} not found", f);
return null; return null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册