Skip to content

withConnection ambiguity #382

@LennysLounge

Description

@LennysLounge

The method withConnection is ambiguous if called like this:

Object value = sql2o.withConnection((con, obj) -> methodThatReturnsAValue(con));

Because the lambda could both return a void and an object the compiler doesnt know which version of withConnection to use.

The workaround is to explicitly call the return (or not) like this:

Object value = sql2o.withConnection((con, obj) -> {
    return methodThatReturnsAValue(con)
});

Sadly the assignment to the variable is not enough for the compiler to notice.

It would be really nice if it were possible to call it in an unambiguous way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions