MinecraftDev icon indicating copy to clipboard operation
MinecraftDev copied to clipboard

`@ModifyConstant` with `boolean` return value incorrectly gets reported as an error

Open ErrorCraft opened this issue 1 year ago • 0 comments

Minecraft Development for IntelliJ plugin version

2023.2.2-1.7.3

IntelliJ version

IntelliJ IDEA 2023.2.6 (Community Edition)

Operating System

Windows 10

Target platform

Mixins

Description of the bug

A @ModifyConstant with a boolean return value can be used to replace an instanceof check with some other check, but it gets incorrectly reported as two errors: one for the Class return type, and one for the method parameters, the latter being #2231. However, it works just fine and replaces the instanceof check as expected.

Reproducable mixin (yarn mappings):

@Mixin(ArmorFeatureRenderer.class)
public class ArmorFeatureRendererMixin {
    @ModifyConstant(
        method = "renderArmor",
        constant = @Constant(
            classValue = ArmorItem.class,
            ordinal = 0
        )
    )
    private boolean instanceOfArmorItemDoWhatever(Object reference, Class<ArmorItem> clazz) {
        return false;
    }
}

ErrorCraft avatar Mar 09 '24 21:03 ErrorCraft