Closed MiniDigger closed 4 years ago
To provide some context for the following, this issue is closely related to GH-8. Both issues are effectively issues with Lorenz's implementation of complete
(though generics are a slightly extended problem).
This issue can be resolved with the following, and I'll be looking to include this change (or one to similar effect) in an upcoming version of Lorenz (0.5.3) - which will then only nessecitate a version bump here.
// Check if there are any methods here that override the return type of a parent
// method.
for (final Map.Entry<MethodSignature, InheritanceType> method : info.getMethods().entrySet()) {
final MethodSignature mappingSignature = mapping.getSignature();
final MethodDescriptor mappingDescriptor = mappingSignature.getDescriptor();
final MethodSignature methodSignature = method.getKey();
final MethodDescriptor methodDescriptor = methodSignature.getDescriptor();
// The method MUST have the same (obf) name, and parameters
if (!Objects.equals(methodSignature.getName(), mappingSignature.getName())) continue;
// TODO: handle generic params
if (!Objects.equals(methodDescriptor.getParamTypes(), mappingDescriptor.getParamTypes())) continue;
if (mappingDescriptor.getReturnType().isAssignableFrom(methodDescriptor.getReturnType(), provider)) {
this.methods.putIfAbsent(methodSignature, mapping);
}
}
edit: see https://github.com/CadixDev/Lorenz/compare/fix/mercury-14
Bumping to say Patchwork needs fix/mercury-14 merged for remapping YarnForge
Bumping to say Patchwork needs fix/mercury-14 merged for remapping YarnForge
Yep, I've been wanting to get this through - though I'm still in need of feedback regarding any possible regressions caused by this commit.
By this point, I think I'll merge it later today and make a release though - can always make another release if things break (but hopefully they don't).
Should be resolved by Lorenz 0.5.3.
Example:
public abstract EntityAgeable createChild(EntityAgeable entityageable);
Overridden:SRG:
MD: net/minecraft/server/EntityAgeable/createChild (Lnet/minecraft/server/EntityAgeable;)Lnet/minecraft/server/EntityAgeable; net/minecraft/world/entity/AgableMob/getBreedOffspring (Lnet/minecraft/world/entity/AgableMob;)Lnet/minecraft/world/entity/AgableMob;
this will remap the method in EntityAgeable, but not in EntityBee, because the return types don't match. Java allows overriding methods with different return types, if the type is a subclass of the OG return type.
This is fixable by adding extra SRGs for the subclasses, but thats rather annoying:
MD: net/minecraft/server/EntityBee/createChild (Lnet/minecraft/server/EntityAgeable;)Lnet/minecraft/server/EntityBee; net/minecraft/world/entity/animal/Bee/getBreedOffspring (Lnet/minecraft/world/entity/AgableMob;)Lnet/minecraft/world/entity/animal/Bee;