Determine evaluation result type without evaluating
I have a use-case where it would be highly beneficial if there would be a possibility to determine the result type an expression will yield (if executed successfully).
Is this already possible with the existing API? I tried to use the AST API but could not find a way.
I think that is impossible because of conditionals (IF). Conditionals might return any type in one of their branches, and you'll only know which if you evaluate the condition.
But I might be wrong here.
For expressions that have no IF and now also SWITCH function, it should be possible.
It could be done externally, using the AST by more or less using the logic in evaluateSubtree().
Instead of executing the calculation, the result would just be the data type.
One would have to take care of some special cases, like adding strings to numbers or durations to date-times etc.
Another (more cleaner) way would require to change the function and operator interfaces, adding a method e.g. determineResultDataType().
Rest would be the same as above, but it would have the advantage of determine the data type would be also in the function/operator class.