Improved TypeInfo.equals logic + proper TypeChecker equals check (how the fuck was this NOT added before you fucking dumdum)

This commit is contained in:
bigguy345 committed 2026-03-10 23:56:01 +02:00
1 parent 4de90ab9c1
commit db909866b8
2 files changed
+28 -16

No files matched your search

@@ -33,6 +33,9 @@ public final class TypeChecker {
if (expected == null) return true; // void can accept anything (shouldn't happen)
if (actual == null) return true; // Can't verify, assume compatible
// Exact match by reference equality
if(expected.equals(actual)) return true;
// Handle array types: compatible if element types are compatible
if (expected.isArray() && actual.isArray()) {
TypeInfo expectedElement = expected.getElementType();
@@ -78,13 +81,6 @@ public final class TypeChecker {
if (expectedName == null || actualName == null) return true;
// Exact match by simple name
if (expectedName.equals(actualName)) return true;
// Exact match by full name
if (expected.getFullName() != null && actual.getFullName() != null) {
if (expected.getFullName().equals(actual.getFullName())) return true;
}
// Primitive widening conversions
if ("number".equals(expectedName) && isNumericType(actualName)) {
@@ -14,11 +14,7 @@ import noppes.npcs.client.gui.util.script.interpreter.method.MethodSignature;
import noppes.npcs.client.gui.util.script.interpreter.token.TokenType;
import java.lang.reflect.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Supplier;
/**
@@ -1273,13 +1269,33 @@ public class TypeInfo {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TypeInfo typeInfo = (TypeInfo) o;
return fullName.equals(typeInfo.fullName);
if (!(o instanceof TypeInfo))
return false;
TypeInfo other = (TypeInfo) o;
if (!fullName.equals(other.fullName))
return false;
if (typeParameterName != null || other.typeParameterName != null) {
if (!Objects.equals(typeParameterName, other.typeParameterName))
return false;
if (!Objects.equals(boundType, other.boundType))
return false;
}
if (!Objects.equals(elementType, other.elementType))
return false;
return true;
}
@Override
public int hashCode() {
return fullName.hashCode();
int result = fullName.hashCode();
if (typeParameterName != null)
result = 31 * result + typeParameterName.hashCode();
if (elementType != null)
result = 31 * result + elementType.hashCode();
return result;
}
}