Skip to content

Static import breaks named argument for methods with default parameters #695

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 Apr 20, 2025 · 0 comments
Open

Comments

@EotT123
Copy link
Contributor

EotT123 commented Apr 20, 2025

When using named arguments with a method that has default parameters, everything works as expected — unless the method is statically imported. In that case, the compiler can no longer resolve the method correctly.

Minimal Reproducible Example:

public record Foo(String text = null){
    public static Foo create(String text = null){
        return new Foo(text);
    }
}

public class Test {
    public Test(Foo foo){
        ...
    }
}

When using a static import for the create method, compilation fails:

import static <package>.Foo.*; // Static import for 'create' method

public class Main {
    public static void main(String[] args) {
        new Test(Foo.create(text:"text")); // OK
        new Test(create(text:"text")); // NOK: Cannot resolve method 'create(manifold_tuple__xxx)
    }
}
EotT123 pushed a commit to EotT123/manifold-test that referenced this issue Apr 20, 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
Projects
None yet
Development

No branches or pull requests

2 participants