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

Fix issue 2943 - UnsolvedSymbolException thrown on Stream.<func>(<some lambda>) #2961

Merged
merged 3 commits into from
Nov 29, 2020

Conversation

qzchenwl
Copy link
Contributor

Fixes #2943.

@@ -187,7 +187,7 @@ void typeOfVoidLambda() {

JavaParserFacade javaParserFacade = JavaParserFacade.get(new ReflectionTypeSolver());
ResolvedType type = javaParserFacade.getType(lambdaExpr);
assertEquals("void", type.describe());
assertEquals("java.util.function.Consumer<? super java.lang.String>", type.describe());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lambda always has "function" type, never be void.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused about the sample used within this test:

import java.util.List;
import java.util.stream.IntStream;

public class Agenda {

    private List<String> persons;

    public void lambdaEmpty() {
        return persons.stream().forEach(p -> {
            System.out.println(p);
        });
    }

}

Note that .forEach() is void return type, AND lambdaEmpty is void return type... So why is there a return ...?

Which means that the original test is "wrong" or otherwise needs amending..?

Copy link
Member

@MysterAitch MysterAitch Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add the above as a comment -- it doesn't change this PR 👍

Note this equivalent code where the parameter to stringConsumer is extracted as a variable with an explicit type:

    public void lambdaEmpty() {
        java.util.function.Consumer<String> stringConsumer = p -> {
            System.out.println(p);
        };
        persons.stream().forEach(stringConsumer);
    }

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

Successfully merging this pull request may close these issues.

UnsolvedSymbolException thrown on Stream.<func>(<some lambda>).
3 participants