You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using lambdas in overlay methods in native JsTypes I am getting this error:
SEVERE: (TypeError) : $wnd.GoldenLayout.lambda$0 is not a function
com.google.gwt.core.client.JavaScriptException: (TypeError) : $wnd.GoldenLayout.lambda$0 is not a function
This method works:
@JsOverlay
public static final void test1() {
int[] a = new int[1];
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
a[0] = 2;
}
});
}
But this doesn't:
@JsOverlay
public static final void test2() {
int[] a = new int[1];
Scheduler.get().scheduleDeferred(() -> a[0] = 2);
}
The text was updated successfully, but these errors were encountered:
The issue here is that lambdas are implemented in the following way. The code for the lambda function is implemented by a static method in the declaring class and then the lambda itself is an anonymous inner class where the SAM method delegates to the static method in the declaring class.
When the declaring class is Native such method is defined in an inconsistent way. The fix in the current review is marking that method as a JsOverlay but this is far from ideal. A better implementation would be to define the static method in the anonymous inner class itself.
The fix is a bit of a hack, a better solution would be
not to mimic the placement of the lambda implematation
by JDT, which is done that way out of necesity (as
lambdas are created dynamically via a factory), and
instead synthesize the method in the anonymous inner
class that is already synthesized to represent the
lambda in GWT.
Bug: gwtproject#9354
Bug-Link: http://github.com/gwtproject/gwt/issues/9354
Change-Id: I749c5ef1356ae5e0ec6a8f2dcabbaa15e4001f9a
When using lambdas in overlay methods in native JsTypes I am getting this error:
This method works:
But this doesn't:
The text was updated successfully, but these errors were encountered: