cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.46k stars 160 forks source link

Fail to transpile a parameterized method application if target is not specified (this or class name not added) #47

Closed renaudpawlak closed 8 years ago

renaudpawlak commented 8 years ago

Normally JSweet adds the missing "this" automatically. Not in that case it seems:

private <T> void installXMLHttpRequestListeners(XMLHttpRequest xhr,Consumer<T> resolve, Consumer<Object> reject) {
        xhr.onload = (Event ev) -> {
            // TODO bug
            //onXMLHttpRequestComplete(xhr, resolve, reject); bug
            // what we must write to avoid the bug
            this.<T>onXMLHttpRequestComplete(xhr, resolve, reject);

            return null;
        };
    }

It looks like an unusual case so we can probably fix it in the next release.

renaudpawlak commented 8 years ago

Normally JSweet automatically adds a this target when calling a method defined on the current class... however, it does not work when the method has generics and defines it own generics. Her is a simpler example:

public class AddThisOnGenericMethods<T> {
    private <U> void m(AddThisOnGenericMethods<U> i) {
    }
    public void m2(AddThisOnGenericMethods<String> i) {
        m(i); // does not work... this not added
    }
}
renaudpawlak commented 8 years ago

It also does not work for parameterized static method as reported in #67. It is actually exactly the same issue transposed to static methods.

renaudpawlak commented 8 years ago

fixed!