private void ensureValidDouble(RankingExpression expression, String expressionDescription, TypeContext<Reference> context) {
        if (expression == null) return;
        TensorType type = resolveType(expression, expressionDescription, context);
        if ( ! type.equals(TensorType.empty))
            throw new IllegalArgumentException("The " + expressionDescription + " must produce a double " +
                                               "(a tensor with no dimensions), but produces " + type);
    }
Resolves the types of all functions in the given profile

@throws IllegalArgumentException if validate is true and the given rank profile does not produce valid types
config-model/src/main/java/com/yahoo/schema/processing/RankingExpressionTypeResolver.java