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

Ambiguity between static method and instance method with one fewer parameter #1208

Open
mhsmith opened this issue Jul 7, 2024 · 0 comments
Labels

Comments

@mhsmith
Copy link
Member

mhsmith commented Jul 7, 2024

We simulate Python's "unbound method" syntax by allowing an instance method to be called on the class with an instance as an extra first argument. However, if there's a static method on the same class that also takes a first argument of that type, it's possible that this could cause an ambiguity which doesn't exist in Java, because it doesn't allow unbound syntax.

If the user has an instance, then the ambiguity can be resolved by calling either method through the instance instead, because in that context the two overloads will no longer have the same number of arguments. But if the user wants to call the static method, and doesn't have an instance to call it through, I don't think there's currently a workaround. So perhaps in the case of an ambiguous call through the class, we should try making another pass only considering static methods?

Or maybe an even simpler solution would be to just disallow unbound syntax for Java methods, since using bound syntax is always an alternative.

@mhsmith mhsmith added the bug label Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant