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

[java] Overloaded field of similar signature was already declared (on extern inline) #11131

Closed
EliteMasterEric opened this issue Apr 13, 2023 · 4 comments
Assignees
Labels
platform-java Everything related to Java

Comments

@EliteMasterEric
Copy link
Contributor

Steps to reproduce:

  • Create an extern inline overload function which takes a Haxe function as a parameter.
  • Create a second extern inline overload function of the same name, also taking a Haxe function as a parameter, but with a different signature.
  • Attempt to build on the Java target.

Expected result:

The expected result is that the appropriate overload is inlined for each use case.

Actual result:

The following compiler error is received:

Another overloaded field of similar signature was already declared : displayItems
... The signatures are different in Haxe, but not in the target language
... The second field is declared here

From what I understand, it is evaluating the two functions as both having the same argument (haxe.lang.Function I believe) when I was under the impression Haxe would inline the code before converting types like this.

Notes:

It is fully reasonable to expect that two overloads should not be able to take the same parameters. However:

  • At compile time, it is fully possible for the compiler to distinguish these two functions, as the only parameter (a generator function in my case) has a different number and type of parameters for each overload.
  • During compilation, these functions will be inlined to their appropriate bodies anyway.
  • After compilation, the resulting code has no ambiguous overloads.

I have not evaluated the effectiveness of this on the JVM target.

@Simn Simn added the platform-java Everything related to Java label Apr 13, 2023
@Simn
Copy link
Member

Simn commented Apr 13, 2023

From your description that indeed sounds like a missing check.

As a general note, it would really help if you included reproducible code examples in your issues. I understand that this can sometimes be difficult when native libraries and whatnot are involved, but in this case it should be quite straightforward.

@EliteMasterEric
Copy link
Contributor Author

@Simn Apologies. Here is a reproduction I created for this issue:

https://github.com/EliteMasterEric/Issue11131

@Simn
Copy link
Member

Simn commented Apr 13, 2023

Thanks! And yes, we should just not check this on externs. There's even a comment saying (* OVERLOADTODO: generalize this and respect whether or not we actually generate the functions *).

@Simn Simn self-assigned this Apr 13, 2023
@Simn Simn closed this as completed in cd43c55 Apr 13, 2023
@Simn Simn added this to the 4.3 Hotfix milestone Apr 13, 2023
@Simn
Copy link
Member

Simn commented Apr 13, 2023

I guess we can 4.3.1 this, should be harmless!

@Simn Simn reopened this Apr 13, 2023
@kLabz kLabz closed this as completed Apr 13, 2023
@kLabz kLabz removed this from the 4.3 Hotfix milestone Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-java Everything related to Java
Projects
None yet
Development

No branches or pull requests

3 participants