From 9d4e0ba442c2cc8ed0378905fc15654f719824ce Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 29 Nov 2022 14:45:04 +0100 Subject: [PATCH] LibWeb: Fix WebIDL overload resolution with platform object arguments We now check if an argument value is a platform object that implements the relevant IDL interface when resolving overloads. This makes passing a Path2D object to CanvasRenderingContext2D.fill() actually choose the Path2D overload. :^) --- Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp b/Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp index acbcf9ccc4..d827d846de 100644 --- a/Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp +++ b/Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp @@ -159,10 +159,15 @@ JS::ThrowCompletionOr resolve_overload(JS::VM& vm, IDL::Effect // - a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types // then remove from S all other entries. else if (value.is_object() && is(value.as_object()) - && has_overload_with_argument_type_or_subtype_matching(overloads, i, [](IDL::Type const& type) { - // FIXME: - an interface type that V implements + && has_overload_with_argument_type_or_subtype_matching(overloads, i, [value](IDL::Type const& type) { + // - an interface type that V implements + if (static_cast(value.as_object()).implements_interface(type.name())) + return true; + + // - object if (type.is_object()) return true; + return false; })) { overloads.remove_all_other_entries();