Skip to content

Optional parameters in extension methods not working #692

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 19, 2025 · 1 comment
Open

Optional parameters in extension methods not working #692

EotT123 opened this issue Apr 19, 2025 · 1 comment

Comments

@EotT123
Copy link
Contributor

EotT123 commented Apr 19, 2025

It appears that optional and named parameters in extension methods aren't functioning correctly.

public class Foo {}

@Extension
public class FooExt {
    public static String test(@This Foo foo, String bar="", String foobar){
        return bar + foobar;
    }
}

new Foo().test("bar", "foobar"); // OK
new Foo().test(bar:"bar", foobar:"foobar"); // NOK when using using named parameters
new Foo().test(foobar:"foobar"); // NOK when only supplying required parameter
EotT123 pushed a commit to EotT123/manifold-test that referenced this issue Apr 19, 2025
#692
EotT123 pushed a commit to EotT123/manifold-test that referenced this issue Apr 19, 2025
@EotT123
Copy link
Contributor Author

EotT123 commented Apr 25, 2025

I've fixed the example, I forgot to add a default value for one of the parameters.

The following warning is also displayed: Maybe missing '@This' to declare an instance extension method?". The first parameter is clearly annotated with @This, but while using the debugger, I noticed that the annotation isn't present in the generated code.

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