MinecraftDev icon indicating copy to clipboard operation
MinecraftDev copied to clipboard

When injecting at certain points and capturing locals, mixin method arguments are highlighted as incorrect

Open Quinteger opened this issue 3 years ago • 2 comments
trafficstars

  • Minecraft Development for IntelliJ plugin version = 2021.3-1.5.18
  • IntelliJ version = 2021.3.1 (213.6461.79)
  • Operating System (this has come up enough times to be worth noting) = win10
  • (optional) Target platform, if relevant = Mixin 0.8.4, Forge 1.16.5-36.2.23
  1. I made a mixin into a method of another mod, so remap = false.

    • Target method is public static, with a generic return parameter T.
    • Injection was an @Inject at "RETURN", with capture of a single local variable.
    • Captured local variable is the only one declared in method body.
    • Therefore, method parameters of my injection looked like ({targetMethodArgs}, CallbackInfoReturnable<T>, LocalVariableType).
    • Everything works nicely, no complaints from the plugin, works ingame.
  2. After that, I change the injection from "RETURN" to "JUMP", opcode = Opcodes.IFEQ, ordinal = 1, there are a total of 2 of those opcodes in the target method.

    • Plugin highlights method parameters of injection as incorrect, error message "Method parameters do not match expected parameters for Inject".
    • Accepting the option "Fix method parameters" does nothing.
    • Mixin still applies and works correctly.
    • Removing the local variable removed the error.

I do understand that both injecting at "JUMP" and capturing locals in the same injection might be undesirable. However, it should probably only raise a warning, or at least remove the offender when using "Fix method parameters".

Quinteger avatar Feb 01 '22 20:02 Quinteger

Also applies when injecting at "INVOKE_ASSIGN"

Quinteger avatar Feb 01 '22 20:02 Quinteger

Relates to #1884

Earthcomputer avatar Nov 24 '23 13:11 Earthcomputer