google / elemental2

Type checked access to browser APIs for Java code.
Apache License 2.0
150 stars 38 forks source link

Patch the closure type for AbortController.abort() to gen correct code #76

Closed realityforge closed 5 years ago

realityforge commented 5 years ago

Prior to this patch the AbortController generated a class

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public class AbortController {
  @JsFunction
  public interface AbortFn {
    Object onInvoke();
  }

  public AbortController.AbortFn abort;
  public AbortSignal signal;
}

However when this was used in a GWT 2.8.2 it would produce incorrect code. For example _abortController.abort.onInvoke() would be compiled to this._abortController.abort.call(null) which would result in an error from the browser.

The patched closure extern will generate working code that looks like:

@JsType( isNative = true, namespace = JsPackage.GLOBAL )
public class AbortController
{
  public AbortSignal signal;

  public native void abort();
}
gkdn commented 5 years ago

Pls send a PR to extern file in Closure instead.

realityforge commented 5 years ago

Closed in favour of https://github.com/google/closure-compiler/pull/3209