public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().typeCheck(visitor, contextInfo); RoleDiagnostic role = new RoleDiagnostic(RoleDiagnostic.UNARY_EXPR, "-", 0); Expression operand = visitor.getConfiguration().getTypeChecker(backwardsCompatible).staticTypeCheck( getBaseExpression(), SequenceType.OPTIONAL_NUMERIC, role, visitor); setBaseExpression(operand); if (operand instanceof Literal) { GroundedValue v = ((Literal) operand).getValue(); if (v instanceof NumericValue) { return Literal.makeLiteral(((NumericValue) v).negate(), this); } } return this; }
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().typeCheck(visitor, contextInfo); RoleDiagnostic role = new RoleDiagnostic(RoleDiagnostic.UNARY_EXPR, "-", 0); Expression operand = visitor.getConfiguration().getTypeChecker(backwardsCompatible).staticTypeCheck( getBaseExpression(), SequenceType.OPTIONAL_NUMERIC, role, visitor); setBaseExpression(operand); if (operand instanceof Literal) { GroundedValue v = ((Literal) operand).getValue(); if (v instanceof NumericValue) { return Literal.makeLiteral(((NumericValue) v).negate(), this); } } return this; }