MinecraftDev
MinecraftDev copied to clipboard
Incorrect `UnresolvedLocalCapture` inspection (using Mixin Extras @Local)
trafficstars
Minecraft Development for IntelliJ plugin version
2024.2-1.8.1
IntelliJ version
2024.2.1
Operating System
Linux
Target platform
Fabric
Description of the bug
mcdev says that @Local does not match any or matched multiple local variables in the target method for both @Local parameters in this mixin, but the mixin works fine.
Injector:
@Inject(
method = "save",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/nbt/CompoundTag;putInt(Ljava/lang/String;I)V"
)
)
private void exampleMixin(CompoundTag tag, CallbackInfoReturnable<CompoundTag> cir, @Local WarpPlatePair pair, @Local(ordinal = 1) CompoundTag pairTag) {
// ...
}
Target:
public CompoundTag save(CompoundTag tag) {
ListTag pairs = new ListTag();
for (WarpPlatePair pair : this.pairs) { // <-- Local I am targetting
CompoundTag pairTag = new CompoundTag(); // <-- Local I am targetting
pairTag.putInt("id", pair.id());
// ...
}
// ...
return tag;
}
Please provide the actual testcase, pseudocode is useless
It's not really pseudocode -
target:
@Override
public CompoundTag save(CompoundTag tag) {
ListTag pairs = new ListTag();
for (WarpPlatePair pair : this.pairs) {
CompoundTag pairTag = new CompoundTag();
pairTag.putInt("id", pair.id());
pairTag.putLong("expiryTime", pair.expiryTime());
pairs.add(pairTag);
}
tag.put("pairs", pairs);
return tag;
}
injector:
@Inject(
method = "save",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/nbt/CompoundTag;putInt(Ljava/lang/String;I)V"
)
)
private void notifier$saveNotifierField(CompoundTag tag, CallbackInfoReturnable<CompoundTag> cir, @Local WarpPlatePair pair, @Local(ordinal = 1) CompoundTag pairTag) {
pairTag.putBoolean("notifiedOfExpiry", ((WarpPlatePairDuck) (Object) pair).notifier$hasNotifiedOfExpiry());
}
It matters how the target method was compiled, can you upload the target bytecode?
Here you go, contains the superfluous stuff like log statements :upside_down_face:
https://hst.sh/uqayoloqeg.properties