google / google/jsinterop-generator

Error when @override method takes a type union as a parameter

Open
#35 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
85
Forks
24
PR merge metrics
No merged PRs in 30d

Description

As part of an attempt to whittle down the remaining errors in `google/elemental2` builds I tried to define the standardized `Document.prototype.write` in an extern accessible via Elemental2.

The extern looks something like:

```javascript
/**
* @param {!TrustedHTML|string} text
* @return {undefined}
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-write
*/
Document.prototype.write = function(text) {};
```

This is overridden in `w3c_dom2.js` with

```javascript
/**
* @param {!TrustedHTML|string} text
* @return {undefined}
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-75233634
* @override
*/
HTMLDocument.prototype.write = function(text) {};
```

Unfortunately `jsinterop-generator` generates the overlay methods for union types in `Document` class like

```java
@JsOverlay
public final void write(TrustedHTML text) {
write(Js.uncheckedCast(text));
}
```

and attempts to define a similar but different overlay in `HTMLDocument` like

```java
@JsOverlay
public final void write(TrustedHTML text) {
write(Js.uncheckedCast(text));
}
```

There does not seem to get the overriding method to use the union type and thus the overlay methods declared by the overridden method. Thus a compile error.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.