isA method
Check wether value of this HTType can be assigned to other HTType.
Implementation
@override
bool isA(HTType? other) {
assert(other?.isResolved ?? true);
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 (other.returnType != null && !other.returnType!.isTop) {
if (returnType != null && !returnType!.isBottom) {
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 != null &&
(param.declType == null ||
otherParam.declType!.isNotA(param.declType)))) {
return false;
}
}
}
return true;
}