Open ostryhub opened 7 years ago
Ok. Looks like there is a problem... not sure if is it JSweet or J4TS's fault. I have never tried this Arrays.copy so far.... will look at it, but you should expect some delay unless it is a blocking issue for anyone.
It is a jsweet fault, more info at #449
Would you like to take a look @schaumb
The transpiler right now can not recognize the candies generated overloaded common functions.
This is why recognizes only one Arrays.copyOf function, which is the syntactically perfect match. The found method has a generic argument, but the overloaded common function has not. (this is the error message)
(If it is in the same compilation unit (not a candy), works well, as expected.)
So I think the solution is that it need to read the candies functions (all syntax), and generate the overloaded common functions (like the original code). This is not an easy task :)
And it can't be hack on j4ts side either because the candy generator the function names gets not the classpath candy jar, but the original java classes. :/
Yes. I have the same problem on another project and ended up with the same conclusion.
Tough dev anyway because the JSweet overload's system isn't that easy.
Let's rename this issue
Simple repro: In a candy
class Abstract {
void setX(int x) {
//
}
}
and in client project:
In a candy
class Impl extends Abstract { // ts compile error - class incorrectly extends Abstract
void setX(String s) {
this.setX(s.hashCode());
}
}
Hi, thanks for the awsome transpiler ! I found an issue with using java Arrays.copy() method.
The problem in short is that when trying to copy an array using generic copy method jsweet has issues with finding the right method to bind.
I created a fork of jsweet-quickstart to enable easy reproduction (in a branch). https://github.com/ostryhub/jsweet-quickstart/tree/issue_with_arrays_copy
And here is the output from transpiling the test code: https://github.com/ostryhub/jsweet-quickstart/blob/issue_with_arrays_copy/output.log
What is interesting is that despite the error I can see the correct js code being generated.
Cheers, Rafal