Inference/src/TypeSystem/UnionType.cs
/// <summary>
/// This method unifies two type expressions (this and te)
/// </summary>
/// <param name="te">The expression to be unfied with this</param>
/// <param name="unification">Indicates if the kind of unification (equivalent, incremental or override).</param>
/// <param name="previouslyUnified">To detect infinite loops. The previously unified pairs of type expressions.</param>
/// <returns>If the unification was successful</returns>
This method unifies two type expressions (this and te)
This method unifies two type expressions ( this and te )
public override bool Unify(TypeExpression te, SortOfUnification unification, IList<Pair<TypeExpression, TypeExpression>> previouslyUnified) {
            Pair<TypeExpression, TypeExpression> pair = new Pair<TypeExpression, TypeExpression>(this, te);
            if (previouslyUnified.Contains(pair))
                return true;
            previouslyUnified.Add(pair);
            bool equivalent = true;
            foreach (TypeExpression type in this.typeSet)
                if (!(equivalent = (bool)type.AcceptOperation(new EquivalentOperation(te), null)))
                    break;
            if (!equivalent)
                return false;
            foreach (TypeExpression type in this.typeSet)
                te.Unify(type, SortOfUnification.Incremental, previouslyUnified);
            this.ValidTypeExpression = false;
            te.ValidTypeExpression = false;
            return true;
        }
public override bool Unify ( TypeExpression te , SortOfUnification unification , IList < Pair < TypeExpression , TypeExpression > > previouslyUnified ) { Pair < TypeExpression , TypeExpression > pair = new Pair < TypeExpression , TypeExpression > ( this , te ) ; if ( previouslyUnified . Contains ( pair ) ) return true ; previouslyUnified . Add ( pair ) ; bool equivalent = true ; foreach ( TypeExpression type in this . typeSet ) if ( ! ( equivalent = ( bool ) type . AcceptOperation ( new EquivalentOperation ( te ) , null ) ) ) break ; if ( ! equivalent ) return false ; foreach ( TypeExpression type in this . typeSet ) te . Unify ( type , SortOfUnification . Incremental , previouslyUnified ) ; this . ValidTypeExpression = false ; te . ValidTypeExpression = false ; return true ; }
This method unifies two type expressions (this and te)
This method unifies two type expressions ( this and te )
// * Infinite recursion detection // * First checks that all the expression are equivalent. Otherwise substitutions could be //   partially applied to type variables that should finally not be unified // * Lets unify, incrementing type variables with union types // * Unification of union types is incremental // * Clears the type expression cache
If the unification was successful
If the unification was successful
te
TypeExpression
The expression to be unfied with this
The expression to be unfied with this
unification
SortOfUnification
Indicates if the kind of unification (equivalent, incremental or override).
Indicates if the kind of unification ( equivalent incremental or override ) .
previouslyUnified
IList<Pair<TypeExpression, TypeExpression>>
To detect infinite loops. The previously unified pairs of type expressions.
To detect infinite loops . The previously unified pairs of type expressions .