-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
@@ -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()); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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..?
There was a problem hiding this comment.
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);
}
…2654, javaparser#2959, javaparser#2948, javaparser#2949, javaparser#2950, javaparser#2955, javaparser#2957, javaparser#2942, javaparser#2958, javaparser#2927, javaparser#2930, javaparser#2931, javaparser#2938, javaparser#2945, javaparser#2947, javaparser#2952, javaparser#2956, javaparser#2954, javaparser#2939, javaparser#2961, javaparser#2966)
Fixes #2943.