mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-18 13:49:12 +00:00
Validate against raw types when validating super because mirror sucks
This commit is contained in:
1 parent
6fa0432fcc
commit
34dab7d1d5
2 files changed
+20
-6
No files matched your search
@@ -29,6 +29,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.AnnotationValue;
|
||||
import javax.lang.model.element.Element;
|
||||
@@ -204,4 +205,20 @@ public abstract class MirrorUtils {
|
||||
}
|
||||
return reference.toString();
|
||||
}
|
||||
|
||||
public static boolean isAssignable(ProcessingEnvironment processingEnv, TypeMirror targetType, TypeMirror superClass) {
|
||||
boolean assignable = processingEnv.getTypeUtils().isAssignable(targetType, superClass);
|
||||
if (!assignable && targetType instanceof DeclaredType && superClass instanceof DeclaredType) {
|
||||
TypeMirror rawTargetType = MirrorUtils.toRawType(processingEnv, (DeclaredType)targetType);
|
||||
TypeMirror rawSuperType = MirrorUtils.toRawType(processingEnv, (DeclaredType)superClass);
|
||||
return processingEnv.getTypeUtils().isAssignable(rawTargetType, rawSuperType);
|
||||
}
|
||||
|
||||
return assignable;
|
||||
}
|
||||
|
||||
private static TypeMirror toRawType(ProcessingEnvironment processingEnv, DeclaredType targetType) {
|
||||
return processingEnv.getElementUtils().getTypeElement(((TypeElement)targetType.asElement()).getQualifiedName()).asType();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import javax.lang.model.type.DeclaredType;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
import org.spongepowered.tools.MirrorUtils;
|
||||
import org.spongepowered.tools.obfuscation.IOptionProvider;
|
||||
import org.spongepowered.tools.obfuscation.MixinValidator;
|
||||
import org.spongepowered.tools.obfuscation.TypeHandle;
|
||||
@@ -79,7 +80,7 @@ public class TargetValidator extends MixinValidator {
|
||||
}
|
||||
|
||||
private boolean validateSuperClass(TypeMirror targetType, TypeMirror superClass) {
|
||||
if (this.isAssignable(targetType, superClass)) {
|
||||
if (MirrorUtils.isAssignable(this.processingEnv, targetType, superClass)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -106,15 +107,11 @@ public class TargetValidator extends MixinValidator {
|
||||
|
||||
private boolean checkMixinsFor(TypeMirror targetType, TypeMirror superClass) {
|
||||
for (TypeMirror mixinType : this.getMixinsTargeting(targetType)) {
|
||||
if (this.isAssignable(mixinType, superClass)) {
|
||||
if (MirrorUtils.isAssignable(this.processingEnv, mixinType, superClass)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected final boolean isAssignable(TypeMirror targetType, TypeMirror superClass) {
|
||||
return this.processingEnv.getTypeUtils().isAssignable(targetType, superClass);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user