SpongePowered / Mixin

Mixin is a trait/mixin and bytecode weaving framework for Java using ASM
MIT License
1.41k stars 194 forks source link

@Invokers with the same name and different signatures are not supported #522

Open PanSzelescik opened 3 years ago

PanSzelescik commented 3 years ago

I have Minecraft class with 2 methods:

private boolean removeBlock(BlockPos p_180235_1_) {
    return this.removeBlock(p_180235_1_, false);
}

private boolean removeBlock(BlockPos p_removeBlock_1_, boolean p_removeBlock_2_) {
    /* ... */
}

The first one is remapped, the second one not, so if you create Invokers:

@Mixin(PlayerInteractionManager.class)
public interface InvokerRemoveBlock {

    @Invoker("removeBlock")
    boolean invoke_removeBlock(BlockPos pos);
    @Invoker(value = "removeBlock", remap = false)
    boolean invoke_removeBlock(BlockPos pos, boolean canHarvest);
}

You will get such Exception: crash-2021-09-04_22.16.45-client.txt

I know there are no such situations in Vanilla and probably in Fabric, but you can find such things in Forge.

Created refmap:

{
  "mappings": {
    "pl/test/mixin/mixins/extrautils2/InvokerRemoveBlock": {
      "removeBlock": "func_180235_c(Lnet/minecraft/util/math/BlockPos;)Z"
    }
  },
  "data": {
    "searge": {
      "pl/test/mixin/mixins/extrautils2/InvokerRemoveBlock": {
        "removeBlock": "func_180235_c(Lnet/minecraft/util/math/BlockPos;)Z"
      }
    }
  }
}

Mixin: 0.8.3 MixinGradle: 0.7-SNAPSHOT ForgeGradle: 3.+ Forge: 1.12.2-14.23.5.2855

Mumfrey commented 2 years ago

Invokers and Accessors are very old part of the toolkit and the method signature/descriptor is not part of their identifier. Thus this is not currently supported but I will look at adding support for this.