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
Regression in jsinterop varargs causing internal compiler error #9932
Comments
Looks like I never added the original stack trace to the issue above, edited now. Likely related stack trace, from building domino-ui-demo with HEAD-SNAPSHOT:
|
(removed, the sample was tested using a newer GWT build than I thought) |
For real this time... This test fails in GWT 2.9.0, with very nearly the same errors shown above for >2.11. public void testVarargsFromJavaToJsinterop() {
nonNativeMethod("A", "B", "C");
}
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name="Console")
public static class Console {
public native void log(Object... values);
}
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name="window")
public static class Global {
public static Console console;
}
private static void nonNativeMethod(Object... values) {
Global.console.log(values);
} Compile error:
Something still has changed in latest GWT after the JDT upgrade that makes this bug easier to encounter, and should be explored to ensure that change isn't also a bug. |
GWT version: HEAD-SNAPSHOT
Browser (with version): any
Operating System: linux
Description
It looks like the JDT update might have changed how we build JMethodCall instances, and broken some jsinterop vararg usages. I'm still working out exactly what is wrong, this ticket is a work in progress, but it looks like the
JMethodCall
now has multiple arguments where previously it had an array of arguments.Steps to reproduce
The sample line of code is
This should be compiled to (in GWT 2.11.0) something like
but in HEAD-SNAPSHOT we see an exception instead:
That exception seems to come from the fact that the JsSafeCloner only considers the
name
property of aJsNameRef
and not theident
gwt/dev/core/src/com/google/gwt/dev/js/JsSafeCloner.java
Lines 145 to 157 in d77e85c
However, there are cases where
name
can be null, andident
then has the relevant information. Applying this fix gets around that stack trace:This at least leads us to emit correct code:
however, this is unnecessarily using the
USING_APPLY_FOR_VARARGS_ARRAY
call style - it appears that the first three vararg elements were detected as being earlier parameters (which do not exist), rather than just components of the vararg parameter. Seeming to confirm that, when debugging 2.11.0,lastArgument
ends up being aJsArrayLiteral
with all four arguments, so thatDIRECT
call style can be used entirely with non-vararg arguments.gwt/dev/core/src/com/google/gwt/dev/js/JsUtils.java
Lines 257 to 270 in d77e85c
Debugging this same code in HEAD-SNAPSHOT ends up with the first three args in
nonVarargArguments
, andlastArgument
is a single local reference.Both issues should be tested, fixed as part of this ticket.
The text was updated successfully, but these errors were encountered: