示例#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 tuple1 && type2 is TupleType tuple2)
            {
                List <DataType> elems1 = tuple1.eltTypes;
                List <DataType> elems2 = tuple2.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 list1 && type2 is ListType list2)
            {
                return(SubsumedInner(list1.ToTupleType(), list2.ToTupleType(), typeStack));
            }
            return(false);
        }