isA method
Check wether value of this HTType can be assigned to other HTType.
Implementation
@override
bool isA(HTType? other) {
if (other == null) return true;
if (other.isTop) return true;
if (other.isBottom) return false;
if (other is HTTypeFunction) return true;
if (other is! HTFunctionType) return false;
if (genericTypeParameters.length != other.genericTypeParameters.length) {
return false;
}
if (returnType.isNotA(other.returnType)) {
return false;
}
for (var i = 0; i < parameterTypes.length; ++i) {
final param = parameterTypes[i];
HTParameterType? otherParam;
if (other.parameterTypes.length > i) {
otherParam = other.parameterTypes[i];
}
if (!param.isOptional && !param.isVariadic) {
if (otherParam == null ||
otherParam.isOptional != param.isOptional ||
otherParam.isVariadic != param.isVariadic ||
otherParam.isNamed != param.isNamed ||
(otherParam.declType.isNotA(param.declType))) {
return false;
}
}
}
return true;
}