diff --git a/src/ap/java/org/spongepowered/tools/obfuscation/mirror/TypeHandle.java b/src/ap/java/org/spongepowered/tools/obfuscation/mirror/TypeHandle.java index 11ed760e..5c2f1e6a 100644 --- a/src/ap/java/org/spongepowered/tools/obfuscation/mirror/TypeHandle.java +++ b/src/ap/java/org/spongepowered/tools/obfuscation/mirror/TypeHandle.java @@ -294,19 +294,16 @@ public class TypeHandle { } /** - * Gets whether this handle is the same as or a supertype of the other handle + * Gets whether this handle is a supertype of the other handle */ - public boolean isAssignableFrom(TypeHandle other) { - if (this.getName().equals(other.getName())) { - return true; - } + public boolean isSuperTypeOf(TypeHandle other) { List superTypes = new ArrayList<>(); if (other.getSuperclass() != null) { superTypes.add(other.getSuperclass()); } superTypes.addAll(other.getInterfaces()); for (TypeHandle superType : superTypes) { - if (this.isAssignableFrom(superType)) { + if (this.name.equals(superType.name) || this.isSuperTypeOf(superType)) { return true; } } diff --git a/src/ap/java/org/spongepowered/tools/obfuscation/validation/TargetValidator.java b/src/ap/java/org/spongepowered/tools/obfuscation/validation/TargetValidator.java index d86661bd..00a0e41d 100644 --- a/src/ap/java/org/spongepowered/tools/obfuscation/validation/TargetValidator.java +++ b/src/ap/java/org/spongepowered/tools/obfuscation/validation/TargetValidator.java @@ -30,6 +30,7 @@ import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; +import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; import org.spongepowered.asm.util.asm.IAnnotationHandle; @@ -110,16 +111,21 @@ public class TargetValidator extends MixinValidator { } private boolean validateSuperClass(TypeHandle targetType, TypeHandle superClass) { - return targetType.isImaginary() || targetType.isSimulated() || superClass.isAssignableFrom(targetType) || this.checkMixinsFor(targetType, superClass); + return targetType.isImaginary() || targetType.isSimulated() || superClass.isSuperTypeOf(targetType) || this.checkMixinsFor(targetType, superClass); } - private boolean checkMixinsFor(TypeHandle targetType, TypeHandle superClass) { - for (TypeHandle mixinType : this.getMixinsTargeting(targetType)) { - if (mixinType.isAssignableFrom(superClass)) { + private boolean checkMixinsFor(TypeHandle targetType, TypeHandle superMixin) { + IAnnotationHandle annotation = superMixin.getAnnotation(Mixin.class); + for (Object target : annotation.getList()) { + if (this.typeHandleProvider.getTypeHandle(target).isSuperTypeOf(targetType)) { return true; } } - - return targetType.getSuperclass() != null && this.checkMixinsFor(targetType.getSuperclass(), superClass); + for (String target : annotation.getList("targets")) { + if (this.typeHandleProvider.getTypeHandle(target).isSuperTypeOf(targetType)) { + return true; + } + } + return false; } }