Thursday, February 26, 2015

JSO: Why does this fail?

Hi,

We switched to gwt 2.7 and now i have a compilation failure

[ERROR] JSNI method JsPromise.thenJava(Lcom/codenvy/api/promises/client/Thenable;)Lcom/codenvy/api/promises/client/Promise; attempts to call method Thenable.then(Ljava/lang/Object;)Lcom/codenvy/api/promises/client/Thenable; on an instance which might be a JavaScriptObject. Such a method call is only allowed in pure Java (non-JSNI) functions.

The code in question does

    @Override
    public final <B> Promise<B> then(final Thenable<B> thenable) {
        if (thenable instanceof JavaScriptObject) {
            return this.thenJs((JavaScriptObject)thenable);
        } else {
            return this.thenJava(thenable);
        }
    }

    private final native <B> Promise<B> thenJs(JavaScriptObject thenable) /*-{
        return this.then(thenable);
    }-*/;

    private final native <B> Promise<B> thenJava(Thenable<B> thenable) /*-{
        return this.then(function() {
            then: function(arg) {
                return thenable.@com.codenvy.api.promises.client.Thenable::then(*)(arg);
            }
        });
    }-*/;

And there's a JSO implementation of the Thenale interface.

I've seen for example https://code.google.com/p/google-web-toolkit/issues/detail?id=9008, but that's not the case as ThenJava will never be called with a JavaScripObject (unless I misunderstood).

So what's the problem?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment