Skip to content

fix(runtime): pick between same-arity overloads by argument type - #60

Merged
triniwiz merged 1 commit into
mainfrom
fix/same-arity-overloads
Nov 21, 2026
Merged

triniwiz merged 1 commit into
mainfrom
fix/same-arity-overloads

Conversation

@triniwiz

Copy link
Copy Markdown
Member

Problem

AppWindow.SetPresenter takes either an AppWindowPresenter or an AppWindowPresenterKind. So appWindow.SetPresenter(AppWindowPresenterKind.FullScreen) threw "Invalid FFI interface argument for expected WinRT type", and apps couldn't go full screen. The same goes for any pair of overloads with the same argument count where neither takes a struct:

  • napi engines and classic static calls: pick_overload fell through to [DefaultOverload], which here is the presenter overload.
  • Classic instance calls: the overload registry kept one method per argument count, so a sibling with the same count was dropped when the method was first bound.

Fix

pick_overload now rules out overloads whose parameters can't take the arguments given, and prefers overloads with more exact kind matches:

  • Ruled out: a number for a class, interface or delegate; an object or string for a number or boolean; and similar clear mismatches.
  • Kept in: conversions a call may still make (a string for a Uri, a number for a TimeSpan) don't rule an overload out.
  • Order: kinds fit, struct fields fit, most struct fields, most exact kinds, [DefaultOverload], metadata order.

The classic registry keeps every overload, deduplicated by parameter types (the class and its interfaces can list a method twice).

  • Instance and static calls with two or more candidates of the same count go through pick_overload (overload_for_call).
  • Calls with one candidate per count take the existing path.

Testing

  • Tested: classic V8 release-with-devtools, in a WinUI 3 app. F11 calls SetPresenter(AppWindowPresenterKind.FullScreen): the window now fills the screen (1536×864), and a second F11 restores it. Before, every call threw.
  • Unit tests added: parameter-kind classification and argument fit (class_helpers::tests). Not run here.
  • Not built: the Hermes, QuickJS, JSC and napi-V8 engines. They share pick_overload through ns_hostobject.rs.

AppWindow.SetPresenter takes an AppWindowPresenter or an
AppWindowPresenterKind. Both take one argument and neither is a struct,
so pick_overload fell through to [DefaultOverload], the presenter
overload, and SetPresenter(AppWindowPresenterKind.FullScreen) threw
"Invalid FFI interface argument for expected WinRT type". On the classic
engine instance calls never got that far: the overload registry kept one
method per arity, so a same-arity sibling was dropped at registration.

pick_overload now also rules out overloads whose parameters can't take
the arguments given (a number for a class, interface or delegate; an
object or string for a number; ...), and prefers more exact kind
matches. Only clear mismatches count, so conversions a call may still
make (a string for a Uri, a number for a TimeSpan) keep an overload in.
Order: kinds fit, struct fields fit, most struct fields, most exact
kinds, [DefaultOverload], metadata order.

The classic registry keeps every overload (deduplicated by parameter
types, since the class and its interfaces can list one method twice),
and instance and static calls with two or more same-arity candidates
go through pick_overload (overload_for_call). Calls with one candidate
per arity take the existing path.
@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0f8e1d90-cb5d-4317-b0ed-5d2d5bd1f9d7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@triniwiz
triniwiz merged commit bb61d3e into main Nov 21, 2026
1 of 3 checks passed
@triniwiz
triniwiz deleted the fix/same-arity-overloads branch November 21, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant