WebIDL compiler problems for function returning Promise<sequence<(File or Directory)>>

RESOLVED FIXED in Firefox 42

Status

()

Core
DOM
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: jwatt, Assigned: bz)

Tracking

Trunk
mozilla42
Points:
---

Firefox Tracking Flags

(firefox41 affected, firefox42 fixed)

Details

Attachments

(4 attachments)

I'm having some issues that I would guess are do to with the WebIDL compiler.

If I add:

  Promise<sequence<(File or Directory)>> getFilesAndDirectories();

to HTMLInputElement.webidl and then implement that using:

  already_AddRefed<Promise>
  HTMLInputElement::GetFilesAndDirectories(ErrorResult& aRv)
  {
     ...
     Sequence<OwningFileOrDirectory> filesAndDirs;
     ...
  }

I get a compiler error because OwningFileOrDirectory is not defined. If I add a bogus attribute to the webidl along the lines of:

  readonly attribute (File or Directory) dummy;

then OwningFileOrDirectory gets defined, and the above code compiles.

Or it gets further at least. At the point that I try to resolve a promise using:

  promise->MaybeResolve(filesAndDirs);

I get a long compiler error due to "error: no matching function for call to 'ToJSValue'".
Created attachment 8625405 [details] [diff] [review]
reduced test patch
Created attachment 8625406 [details]
compiler error calling MaybeResolve
Flags: needinfo?(bzbarsky)
Created attachment 8625419 [details] [diff] [review]
part 1.  When getting all types, include the types Promises are parametrized over
Attachment #8625419 - Flags: review?(peterv)
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Created attachment 8625420 [details] [diff] [review]
part 2.  Add a ToJSValue overload for owning unions
Attachment #8625420 - Flags: review?(peterv)
Yeah, so there are two issues here:

1)  We don't look at the types promises are parametrized over to find union types.
2)  There is no ToJSValue implementation for unions.

The above patches fix this at least for owning unions.  If we decide we want a ToJSValue for non-owning ones, we can add that at that point.
Flags: needinfo?(bzbarsky)
(Reporter)

Updated

3 years ago
Blocks: 1177688
Attachment #8625419 - Flags: review?(peterv) → review+
Attachment #8625420 - Flags: review?(peterv) → review+
https://hg.mozilla.org/mozilla-central/rev/af4c4a299351
https://hg.mozilla.org/mozilla-central/rev/cdc662c32bb2
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
status-firefox42: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla41

Updated

3 years ago
Target Milestone: mozilla41 → mozilla42
You need to log in before you can comment on or make changes to this bug.