Inference/src/TypeSystem/UnionType.cs
/// <summary>
/// This static helper method group a newType into a union collection of types.
/// </summary>
/// <param name="collection">The collection of type (or simply one type)</param>
/// <param name="newType">The type to be added</param>
/// <returns>The union collection of types</returns>
This static helper method group a newType into a union collection of types.
This static helper method group a newType into a union collection of types .
public static TypeExpression collect(TypeExpression collection, TypeExpression newType)
        {
            if (newType == null)
                return collection;
            if (collection == null)
                return newType;
            UnionType union = collection as UnionType;
            if (collection != null)
                union = new UnionType(collection);
            if (newType is UnionType)
            {
                union.AddType(newType);
                return union;
            }
            if (union.AddType(newType))
                return union;
            return collection;
        }
public static TypeExpression collect ( TypeExpression collection , TypeExpression newType ) { if ( newType == null ) return collection ; if ( collection == null ) return newType ; UnionType union = collection as UnionType ; if ( collection != null ) union = new UnionType ( collection ) ; if ( newType is UnionType ) { union . AddType ( newType ) ; return union ; } if ( union . AddType ( newType ) ) return union ; return collection ; }
This static helper method group a newType into a union collection of types.
This static helper method group a newType into a union collection of types .
// both types are unions // * If two elements are the same, retuns the first
The union collection of types
The union collection of types
collection
TypeExpression
The collection of type (or simply one type)
The collection of type ( or simply one type )
newType
TypeExpression
The type to be added
The type to be added