Repository navigation
fix: generics closed over an enum resolve the right IID - #34
Merged
Merged
Conversation
`Signature::get_string` reduced every enum to `Int32`, including inside generic type arguments, so `IAsyncOperation<VibrationAccessStatus>` was asked for the IID of `IAsyncOperation<Int32>` and every member failed to construct. The same broke `IVector<Enum>` and computed the wrong IID for `IReference<Enum>`. Enums now keep their name inside type arguments and become `Int32` only where a value crosses the ABI: `substitute_type_vars` lowers a top-level `Var!N` enum, as do the delegate helpers and the `IReference<T>` return path. An `IReference<Enum>` parameter is boxed as a real `IReference<Enum>` instead of a `PropertyValue` Int32.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
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
Any WinRT generic closed over an enum was unusable on every engine. For example,
VibrationDevice.RequestAccessAsync()andGeolocator.RequestAccessAsync()both returnIAsyncOperation<Enum>, and calling them failed with:So
NSWinRT.toPromise(op)threw.IVector<Enum>failed the same way, for exampleDevicePicker().Filter.SupportedDeviceClasses.Cause:
Signature::get_stringreduced every enum toInt32, including inside generic type arguments. The closed type's IID therefore came fromIAsyncOperation<Int32>rather thanIAsyncOperation<VibrationAccessStatus>, and the QueryInterface call failed. The IID builder itself was correct; it computes the right IID when given the enum name.Fix
get_string_in(.., in_type_arg)), so the IID hashesenum(Name;i4).Int32only where a value crosses the ABI.substitute_type_varsis now depth-aware: aVar!Nat the top level goes throughabi_type_arg, and one nested inside another generic keeps its name. The delegate helpers (delegate_param_sigs,delegate_return_from_invoke) and theIReference<T>return path lower the same way.IReference<Enum>parameters: these are now boxed as a realIReference<Enum>throughstruct_reference::create.PropertyValuecan only produceIReference<Int32>, which matched only because the old IID was wrong in the same way.substitute_type_varsused chainedstr::replace, which turnedVar!10into<arg1>0. The new scanner parses the full index.Tests
windows-napinpm test(newenum-generic-test.js)interop_test::enum_type_argumentspackages/test/enum-check.json QuickJS, Hermes, V8, JSCinterop-check.js22/22 eachThe new Node and classic tests both fail without the fix.
Typings
Running
typings-generatorwith this change emits the enum type where it used to emitnumber, e.g.IAsyncOperation<Windows.Devices.Haptics.VibrationAccessStatus>instead ofIAsyncOperation<number>. The output type-checks with the same errors as before.