Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot remap method overriding with generic parameter #8

Open
qouteall opened this issue Feb 28, 2020 · 2 comments
Open

Cannot remap method overriding with generic parameter #8

qouteall opened this issue Feb 28, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@qouteall
Copy link

qouteall commented Feb 28, 2020

Example:

//mc code
public abstract class Feature<FC extends FeatureConfig>{
    public abstract boolean generate(IWorld world, ChunkGenerator<? extends ChunkGeneratorConfig> generator, Random random, BlockPos pos, FC config);
}

//my code
public class SimpleSpawnerFeature extends Feature<DefaultFeatureConfig>{
    @Override
    public boolean generate(
        IWorld world,
        ChunkGenerator<? extends ChunkGeneratorConfig> generator,
        Random random,
        BlockPos pos,
        DefaultFeatureConfig config
    ){...}
}

In my code this "generate" cannot be remapped.
In AbstractClassMappingImpl#getMethodMapping, the input signature is MethodSignature{name=generate, descriptor=(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Ljava/util/Random;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/gen/feature/DefaultFeatureConfig;)Z}

And in this.methods it has MethodSignature{name=generate, descriptor=(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Ljava/util/Random;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/gen/feature/FeatureConfig;)Z}
So getMethodMapping will return null in this case.

Possible solution:
In AbstractClassMappingImpl#getMethodMapping, if it cannot find the method mapping that exactly match the signature, then find the method mapping that has the same name.

@jamierocks
Copy link
Member

Perhaps we could add a computeMethodMapping to Lorenz, that in the absence of a mapping checks for other mappings of the same name that can assign to the exact signature?

Thoughts @Minecrell ?

@jamierocks jamierocks added the bug Something isn't working label Feb 28, 2020
jamierocks added a commit that referenced this issue May 8, 2020
@dimitriye98
Copy link

dimitriye98 commented Jun 4, 2021

I implemented a work around of this issue in my project, see https://github.com/dimitriye98/filigree/blob/f7530776bff4eaedc259d317a06ef5684a8f4a56/src/main/java/com/dimitriye/filigree/remapper/SimpleRemapperVisitor.java#L105

If you're interested, I could compose a pull request to add it to the upstream. I haven't done so yet as my workaround is kinda hacky in that it bypasses Lorenz and Bombe and just crawls the AST.

As best as I can tell, an actual solution would require incorporating type parameter support into Lorenz, Bombe, and Mercury. I briefly considered forking and trying at it, but this hot fix is good enough for my purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants