Repository navigation
Conversation
Generate `@JSExport` multiplexer methods and setters on `Mock*Target`
when a mocked JS interop `extension type` exposes multiple external
members bound to the same JS property name (such as `(TrustedHTML or
String)` DOM overloads in `package:web`).
- Rename colliding concrete overrides on `Mock*Target` (including
`unsupportedMembers` without `fallbackGenerators`) to distinct
`$mockito$get$...`, `$mockito$set$...`, and `$mockito$method$...`
export keys so `createJSInteropWrapper` passes CFE `ExportChecker`
validation, while preserving paired strict getter + strict setter
exports under a shared JS property name.
- Dispatch incoming JS calls by arity and `JSAny?.isA<T>()` /
`isA<T?>()` runtime checks across primitives, SDK JS types, and
nominal `@JS` extension types, boxing mixed return types via `.toJS`.
- Throw `InvalidMockitoAnnotationException` at `build_runner` time when
active `@JS` overloads are indistinguishable at runtime (such as
colliding getters, method/accessor conflicts, `int` vs. `double` JS
numbers, or anonymous object-literal extension types), guiding users
to `MockSpec(unsupportedMembers: {#...})`.
PR HealthChangelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with |
Import `js_interop_overloads.dart` directly from `builder.dart` instead of linking it via `part` / `part of`, passing explicit target metadata and the library's `JsTypeReferenceResolver` callback into `JsExportPlan`.
…nd expand tests - Support non-JS extension types wrapping primitives on overloaded `@JS` parameters and mixed return types. - Preserve `@JSExport` property names for `unsupportedMembers` entries when their slot in the JS export bucket is unoccupied, disambiguating only on collision. - Respect per-candidate parameter nullability past `firstOptional` during optional overload dispatch synthesis. - Unify representation-chain walking, parameter classification, conflict diagnostics, and cached `JsExportPlan` resolution on `_MockTarget`. - Match allocator import prefixes dynamically in `custom_mocks_test.dart` and add unit and browser (`dart2js` / `dart2wasm`) coverage in `js_interop_overloads_test.dart` and `dart_js_interop_test.dart`.
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.
Generate
@JSExportmultiplexer methods and setters onMock*TargetsoMockSpecsupports JS interopextension types with multiple external members bound to the same JS property name, such as(TrustedHTML or String)DOM overloads in dart-lang/web#596.Mock*Targetexport under distinct$mockito$...keys while paired getters and setters still share one JS property. This includesunsupportedMemberswithoutfallbackGenerators, preventing concreteUnsupportedErrorstubs from colliding with active overloads.$jsExport$set$<name>and$jsExport$method$<name>multiplexers dispatch by arity andJSAny?.isA<T>()/isA<T?>()checks. Primitive, SDK JS, and nominal@JSextension type arguments route to the matchingInvocationstub, boxing mixed return types via.toJS.InvalidMockitoAnnotationExceptionandunsupportedMembersguidance. Colliding getters, method/accessor conflicts,intvs.doubleJS numbers, and anonymous@JS()object-literal extension types cannot be distinguished byinstanceofortypeofin JavaScript.