Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug lambda with diamond operator and several interfaces #2985

Closed
lodart opened this issue May 23, 2019 · 1 comment · Fixed by #3006
Closed

Bug lambda with diamond operator and several interfaces #2985

lodart opened this issue May 23, 2019 · 1 comment · Fixed by #3006
Labels

Comments

@lodart
Copy link
Contributor

lodart commented May 23, 2019

Hi,

There seems to be an error with a particular use of lambda expressions :

public interface TestLambda{
    default <T extends Ben & Jerry> Optional<T> bar () {
        return (Optional<T>) foo().stream().filter(elt -> elt.benMethod(Ben.class)).findFirst();
    }

    default <T extends Ben & Jerry> List<T> foo () {
        return Collections.emptyList();
    }
}

benMethod being a method declared in Ben interface.
It becomes :

public interface TestLambda {
    default <T extends Ben & Jerry> Optional<T> bar() {
        return ((Optional<T>) (foo().stream().filter((Ben & Jerry elt) -> elt.benMethod(Ben.class)).findFirst()));
    }

    default <T extends Ben & Jerry> List<T> foo() {
        return Collections.emptyList();
    }
}

(Notice the (Ben & Jerry elt) -> that doesn't compile)

Thank you for your support :)

@nharrand
Copy link
Collaborator

Hi @lodart ,
Thanks a lot for the bug report.
Would you make a pull request with a failing test out of it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants