Closed Bug 1176800 Opened 9 years ago Closed 9 years ago

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

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla42
Tracking Status
firefox41 --- affected
firefox42 --- fixed

People

(Reporter: jwatt, Assigned: bzbarsky)

References

Details

Attachments

(4 files)

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'".
Flags: needinfo?(bzbarsky)
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
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)
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
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
Target Milestone: mozilla41 → mozilla42
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: