From a47ddbf95319ff373e6f0e0fd3b855ef19409d85 Mon Sep 17 00:00:00 2001 From: SavageVictor Date: Wed, 29 Apr 2026 02:44:06 +0200 Subject: [PATCH] Fix ResolverSyntheticInstanceof incorrectly converting non-boolean ModifyExpressionValue to ModifyInstanceofValue --- .../resolver/special/ResolverSyntheticInstanceof.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/src/main/java/org/sinytra/adapter/patch/resolver/special/ResolverSyntheticInstanceof.java b/core/src/main/java/org/sinytra/adapter/patch/resolver/special/ResolverSyntheticInstanceof.java index 3ea9b4e..a08b284 100644 --- a/core/src/main/java/org/sinytra/adapter/patch/resolver/special/ResolverSyntheticInstanceof.java +++ b/core/src/main/java/org/sinytra/adapter/patch/resolver/special/ResolverSyntheticInstanceof.java @@ -1,6 +1,7 @@ package org.sinytra.adapter.patch.resolver.special; import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.objectweb.asm.tree.*; import org.sinytra.adapter.patch.config.Configurations; import org.sinytra.adapter.env.ctx.MixinContext; @@ -58,6 +59,15 @@ public ResolutionResult resolve(MixinContext context, Recipe recipe) { if (cleanMatcher.test(dirtyMatcher)) { // ModifyExpressionValue doesn't include the original instanceof call, so we can skip comparing instructions if (this.skipInsnComparison) { + // Only convert to @ModifyInstanceofValue if the handler returns boolean. + // If it returns a non-boolean type (e.g. Block), the mixin is modifying the + // value fed into the instanceof check, not the boolean result of it. + // Converting in that case produces an invalid (Block)Block handler where (Z)Z is expected. + Type handlerReturnType = Type.getReturnType(context.methodNode().desc); + if (!handlerReturnType.equals(Type.BOOLEAN_TYPE)) { + return ResolutionResult.pass(); + } + TypeInsnNode instanceOfInsn = (TypeInsnNode) findLabelInsns(insn).stream().filter(i -> i.getOpcode() == Opcodes.INSTANCEOF).findFirst().orElse(null); if (instanceOfInsn == null) { return ResolutionResult.pass();