Пример #1
0
 @Override
 public Type union(final Type t) {
   if (instanceOf(t)) return t;
   if (t instanceof ArrayType) {
     final ArrayType mt = (ArrayType) t;
     return mt.instanceOf(this) ? this : get(retType.union(mt.retType));
   }
   return t instanceof MapType ? ANY_FUN : t instanceof FuncType ? t.union(this) : AtomType.ITEM;
 }
Пример #2
0
 @Override
 public ArrayType intersect(final Type t) {
   // case for item() and compatible FuncType, e.g. function(xs:anyAtomicType) as item()*
   // also excludes FuncType.ANY_FUN
   if (instanceOf(t)) return this;
   if (t instanceof ArrayType) {
     final ArrayType mt = (ArrayType) t;
     if (mt.instanceOf(this)) return mt;
     final SeqType rt = retType.intersect(mt.retType);
     return rt == null ? null : get(rt);
   }
   if (t instanceof FuncType) {
     final FuncType ft = (FuncType) t;
     if (ft.argTypes.length == 1 && ft.argTypes[0].instanceOf(SeqType.ITR)) {
       final SeqType rt = retType.intersect(ft.retType);
       return rt == null ? null : get(rt);
     }
   }
   return null;
 }