Inference/src/TypeSystem/UnionType.cs
/// <summary>
/// Gets the simplified version of the typeexpression.
/// </summary>
/// <returns>Returns the simplified type.</returns>
Gets the simplified version of the typeexpression.
Gets the simplified version of the typeexpression .
public override TypeExpression Simplify(bool includeTypeVariables = true)
        {
            List<TypeExpression> typeSet = new List<TypeExpression>();
            IDictionary<string,TypeExpression> evaluated = new Dictionary<string, TypeExpression>();
            for (int i = 0; i < this.TypeSet.Count; i++)
            {
                foreach (var type in GetTypes(this.TypeSet[i], includeTypeVariables, evaluated))
                {
                    typeSet.Add(type.Simplify());
                }
            }
            typeSet = new List<TypeExpression>(new HashSet<TypeExpression>(typeSet));
            if (typeSet.Count == 0)
                return this;
            else if (typeSet.Count == 1)
                return typeSet[0];            
            else
            {
                UnionType ut = (UnionType)this.CloneType(new Dictionary<TypeVariable, TypeVariable>());
                ut.typeSet = typeSet;                
                return ut;
            }
        }
public override TypeExpression Simplify ( bool includeTypeVariables = true ) { List < TypeExpression > typeSet = new List < TypeExpression > ( ) ; IDictionary < string , TypeExpression > evaluated = new Dictionary < string , TypeExpression > ( ) ; for ( int i = 0 ; i < this . TypeSet . Count ; i ++ ) { foreach ( var type in GetTypes ( this . TypeSet [ i ] , includeTypeVariables , evaluated ) ) { typeSet . Add ( type . Simplify ( ) ) ; } } typeSet = new List < TypeExpression > ( new HashSet < TypeExpression > ( typeSet ) ) ; if ( typeSet . Count == 0 ) return this ; else if ( typeSet . Count == 1 ) return typeSet [ 0 ] ; else { UnionType ut = ( UnionType ) this . CloneType ( new Dictionary < TypeVariable , TypeVariable > ( ) ) ; ut . typeSet = typeSet ; return ut ; } }
Gets the simplified version of the typeexpression.
Gets the simplified version of the typeexpression .
//this.typeSet = typeSet;
Returns the simplified type.
Returns the simplified type .
includeTypeVariables
bool