Repository navigation
fix(runtime): pick between same-arity overloads by argument type - #60
Merged
Merged
Conversation
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.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AppWindow.SetPresentertakes either anAppWindowPresenteror anAppWindowPresenterKind. SoappWindow.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:pick_overloadfell through to[DefaultOverload], which here is the presenter overload.Fix
pick_overloadnow rules out overloads whose parameters can't take the arguments given, and prefers overloads with more exact kind matches:Uri, a number for aTimeSpan) don't rule an overload out.[DefaultOverload], metadata order.The classic registry keeps every overload, deduplicated by parameter types (the class and its interfaces can list a method twice).
pick_overload(overload_for_call).Testing
release-with-devtools, in a WinUI 3 app. F11 callsSetPresenter(AppWindowPresenterKind.FullScreen): the window now fills the screen (1536×864), and a second F11 restores it. Before, every call threw.class_helpers::tests). Not run here.pick_overloadthroughns_hostobject.rs.