//-----------------------------------------------
// QilReplaceVisitor methods
//-----------------------------------------------
/// <summary>
/// Once children have been replaced, the Xml type is recalculated.
/// </summary>
protected virtual void RecalculateType(QilNode node, XmlQueryType oldType)
{
XmlQueryType newType;
newType = QilTypeChecker.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;
}