Fix: Properly handle arrays when checking if members are owned by mixins.

No longer throws when a method call is on an array.

Closes #147
This commit is contained in:
LlamaLad7 committed 2024-10-30 15:11:44 +00:00
1 parent 0b6875f972
commit c516fb7d3f
2 files changed
+11 -2

No files matched your search

@@ -331,6 +331,15 @@ public abstract class MemberRef {
*/
public abstract void setDesc(String desc);
/**
* Whether the owner of this member is a mixin.
* @return Whether the owner of this member is a mixin.
*/
public boolean ownerIsMixin() {
String owner = getOwner();
return !owner.startsWith("[") && ClassInfo.forName(owner).isMixin();
}
@Override
public String toString() {
return String.format("%s for %s.%s%s%s", Bytecode.getOpcodeName(this.getOpcode()), this.getOwner(), this.getName(), this.isField() ? ":" : "",
@@ -600,7 +600,7 @@ public class MixinTargetContext extends ClassContext implements IMixinContext {
} else if (this.detachedSuper || this.inheritsFromMixin) {
if (methodRef.getOpcode() == Opcodes.INVOKESPECIAL) {
this.updateStaticBinding(method, methodRef);
} else if (methodRef.getOpcode() == Opcodes.INVOKEVIRTUAL && ClassInfo.forName(methodRef.getOwner()).isMixin()) {
} else if (methodRef.getOpcode() == Opcodes.INVOKEVIRTUAL && methodRef.ownerIsMixin()) {
this.updateDynamicBinding(method, methodRef);
}
}
@@ -903,7 +903,7 @@ public class MixinTargetContext extends ClassContext implements IMixinContext {
+ " but is mixin.");
}
methodRef.setOwner(superMethod.getImplementor().getName());
} else if (ClassInfo.forName(methodRef.getOwner()).isMixin()) {
} else if (methodRef.ownerIsMixin()) {
throw new MixinTransformerError("Error resolving " + methodRef + " in " + this);
}
}