Skip to content

Incorrect IntelliJ error when using method reference for constructor with optional parameters #704

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

Open
EotT123 opened this issue May 10, 2025 · 0 comments

Comments

@EotT123
Copy link
Contributor

EotT123 commented May 10, 2025

IntelliJ incorrectly flags a method reference to a constructor that includes optional parameters (without providing all optional parameters) as an error, even though the code compiles fine.

public class Foo {
    public Foo(String test, String bar="bar") { }
}

Function<String, Foo> fooFunction = test -> new Foo(test);
Function<String, Foo> fooFunction2 = Foo::new; // ERROR Bad return type in method reference: cannot convert void to test.Test.Foo
BiFunction<String, String, Foo> fooFunction3 = Foo::new; // OK when all parameters are provided
EotT123 pushed a commit to EotT123/manifold-test that referenced this issue May 10, 2025
EotT123 pushed a commit to EotT123/manifold-test that referenced this issue May 23, 2025
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

No branches or pull requests

1 participant