Open Bug 1224090 Opened 9 years ago Updated 2 years ago

Make Web IDL bindings support union type as the type of the distinguishing argument in overload resolution

Categories

(Core :: DOM: Bindings (WebIDL), defect, P3)

defect

Tracking

()

Tracking Status
firefox45 --- affected

People

(Reporter: kaku, Unassigned)

References

(Blocks 1 open bug)

Details

This issue was raised while implementing the following functionality. (Bug1141979 comment50) WebIDL: typedef (HTMLImageElement or HTMLVideoElement or HTMLCanvasElement or Blob or ImageData or CanvasRenderingContext2D or ImageBitmap) ImageBitmapSource; [NoInterfaceObject, Exposed=(Window,Worker)] interface ImageBitmapFactories { [Throws] Promise<ImageBitmap> createImageBitmap(ImageBitmapSource aImage); [Throws] Promise<ImageBitmap> createImageBitmap(BufferSource aBuffer, long aOffset, long aLength, ImageBitmapFormat aFormat, ImagePixelLayout aLayout); }; ImageBitmapFactories::createImageBitmap() is overloaded with union types, which is not supported now.
This was a good bit of work (as in, required rejiggering a bunch of the union code to support not throwing an exception in this situation, at least) last I checked...
Summary: Make Web IDL bindings support distinguishing union type → Make Web IDL bindings support union type as the type of the distinguishing argument in overload resolution
It's worse than just exceptions. Consider this case: interface Foo { void bar((Interface1 or DOMString) arg); void bar(Interface2 arg); }; or worse yet: interface Foo { void bar((Interface1 or DOMString) arg); void bar((Interface2 or long) arg); }; We need to avoid coercion to a primitive before we check both interface types, _and_ we need to avoid coercion to the wrong primitive. This really does not play well with our current "try to convert to the type and see if it works" approach to overload resolution.
Component: DOM → DOM: Core & HTML
Component: DOM: Core & HTML → DOM: Bindings (WebIDL)
Severity: normal → S3
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.