private DataType resolveBackwards(TypeContext context) {
        int i = expressions().size();
        var type = getOutputType(context); // A nested statement; output imposed from above
        if (type == null) // otherwise the last expression will be an output deciding the type
            type = expressions().get(--i).getInputType(context);
        while (--i >= 0) {
            type = expressions().get(i).setOutputType(type, context);
            type = expressions().get(i).assignInputType(type);
        }
        return type;
    }
Resolves types backwards and returns the required input, or null if resolution could not progress to the start.
indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/expressions/StatementExpression.java