System.Xml.Xsl.Qil.QilReplaceVisitor.RecalculateType C# (CSharp) Method

RecalculateType() protected method

Once children have been replaced, the Xml type is recalculated.
protected RecalculateType ( QilNode node, XmlQueryType oldType ) : void
node QilNode
oldType XmlQueryType
return void
        protected virtual void RecalculateType(QilNode node, XmlQueryType oldType) {
            XmlQueryType newType;

            newType = f.TypeChecker.Check(node);

            // Note the use of AtMost to account for cases when folding of Error nodes in the graph cause
            // cardinality to be recalculated.
            // For example, (Sequence (TextCtor (Error "error")) (Int32 1)) => (Sequence (Error "error") (Int32 1))
            // In this case, cardinality has gone from More to One
            Debug.Assert(newType.IsSubtypeOf(XmlQueryTypeFactory.AtMost(oldType, oldType.Cardinality)), "Replace shouldn't relax original type");

            node.XmlType = newType;
        }
    }