Inference/src/TypeSystem/Operations/CloneTypeVariablesOperation.cs
/// <summary>
/// Method that clones each type variable of a type expression.
/// Equivalence classes are not cloned (but included in the equivalenceClasses parameter.
/// The default implementation is do nothing (for built-in types).
/// </summary>
Method that clones each type variable of a type expression.
Equivalence classes are not cloned (but included in the equivalenceClasses parameter.
The default implementation is do nothing (for built-in types).
Method that clones each type variable of a type expression . Equivalence classes are not cloned ( but included in the equivalenceClasses parameter . The default implementation is do nothing ( for built - in types ) .
public override object Exec(TypeVariable tv) {
            if (this.typeVariableMappings.ContainsKey(tv))
                return this.typeVariableMappings[tv];
            TypeVariable newOne = TypeVariable.NewTypeVariable;
            newOne.IsDynamic = tv.IsDynamic;
            this.typeVariableMappings[tv] = newOne;
            if (tv.EquivalenceClass != null && !this.equivalenceClasses.Contains(tv.EquivalenceClass))
                this.equivalenceClasses.Add(tv.EquivalenceClass);
            if (tv.Substitution != null) {
                TypeExpression clonedSubstitution = (TypeExpression)tv.Substitution.Exec(this);
                newOne.addToMyEquivalenceClass(clonedSubstitution, SortOfUnification.Equivalent, new List<Pair<TypeExpression, TypeExpression>>());
            }
            else if (tv.EquivalenceClass != null)
                newOne.EquivalenceClass = tv.EquivalenceClass;
            newOne.ValidTypeExpression = false;
            return newOne;
        }
public override object Exec ( TypeVariable tv ) { if ( this . typeVariableMappings . ContainsKey ( tv ) ) return this . typeVariableMappings [ tv ] ; TypeVariable newOne = TypeVariable . NewTypeVariable ; newOne . IsDynamic = tv . IsDynamic ; this . typeVariableMappings [ tv ] = newOne ; if ( tv . EquivalenceClass != null && ! this . equivalenceClasses . Contains ( tv . EquivalenceClass ) ) this . equivalenceClasses . Add ( tv . EquivalenceClass ) ; if ( tv . Substitution != null ) { TypeExpression clonedSubstitution = ( TypeExpression ) tv . Substitution . Exec ( this ) ; newOne . addToMyEquivalenceClass ( clonedSubstitution , SortOfUnification . Equivalent , new List < Pair < TypeExpression , TypeExpression > > ( ) ) ; } else if ( tv . EquivalenceClass != null ) newOne . EquivalenceClass = tv . EquivalenceClass ; newOne . ValidTypeExpression = false ; return newOne ; }
Method that clones each type variable of a type expression.
Method that clones each type variable of a type expression .
// * If the variable to be cloned already has a map, we return the latter // * Sets the mapping between the old and new one in the typeVariableMappings parameter // * Add both equivalence classes to the equivalenceClasses parameter // * Assigns a clone of the substitution when it previously exists // * Returns the new type variable
tv
TypeVariable