isSubtypeOf method

  1. @override
bool isSubtypeOf(
  1. XPathType other
)
override

Whether this type is equal to or a subtype of other.

Implementation

@override
bool isSubtypeOf(XPathType other) {
  if (super.isSubtypeOf(other)) return true;
  if (other is XPathFunctionType) {
    if (other.isAny) return true;
    if (isAny) return false;
    if (parameterTypes!.length != other.parameterTypes!.length) return false;
    for (var i = 0; i < parameterTypes!.length; i++) {
      // Contravariance: other.parameter must be a subtype of this.parameter.
      if (!other.parameterTypes![i].isSubtypeOf(parameterTypes![i])) {
        return false;
      }
    }
    if (other.returnType != null) {
      if (returnType == null) return false;
      // Covariance: this.returnType must be a subtype of other.returnType.
      if (!returnType!.isSubtypeOf(other.returnType!)) {
        return false;
      }
    }
    return true;
  }
  return false;
}