示例#1
0
        private bool subsumedInner(DataType type1, DataType type2, TypeStack typeStack)
        {
            if (typeStack.contains(type1, type2))
            {
                return(true);
            }

            if (type1.isUnknownType() || type1 == DataType.None || type1.Equals(type2))
            {
                return(true);
            }

            if (type1 is TupleType && type2 is TupleType)
            {
                List <DataType> elems1 = ((TupleType)type1).eltTypes;
                List <DataType> elems2 = ((TupleType)type2).eltTypes;

                if (elems1.Count == elems2.Count)
                {
                    typeStack.push(type1, type2);
                    for (int i = 0; i < elems1.Count; i++)
                    {
                        if (!subsumedInner(elems1[i], elems2[i], typeStack))
                        {
                            typeStack.pop(type1, type2);
                            return(false);
                        }
                    }
                }
                return(true);
            }

            if (type1 is ListType && type2 is ListType)
            {
                return(subsumedInner(((ListType)type1).toTupleType(), ((ListType)type2).toTupleType(), typeStack));
            }
            return(false);
        }