Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

nikeokoronkwo
Copy link
Collaborator

@nikeokoronkwo nikeokoronkwo commented Sep 9, 2025

Fixes #464
Fixes #463

This PR adds support for transforming conditional types (t extends a ? b : c) and predicate types (t is a), and generates Dart alternatives to these types.

Predicate types are converted to booleans, while conditional types are converted to unions, since the result can either be one or the other. There currently isn't a way (afaik) to introspect into parameter values to give a specific result depending on the parameter result.

We could be smart, however, and wrap such methods with other methods to do the casting for us in the case of conditional types, and could try to do similar in predicate types (via assert checks and more).

Fixes dart-lang#464 Fixes dart-lang#463

This PR adds support for transforming conditional types (`t extends a ?
b : c`) and predicate types (`t is a`), and generates Dart alternatives
to these types.

Predicate types are converted to booleans, while conditional types are
converted to unions, since the result can either be one or the other.
There currently isn't a way (afaik) to introspect into parameter values
to give a specific result depending on the param result.

We could be smart, however, and wrap such methods with other methods to
do the casting for us in the case of conditional types, and could _try_
to do similar in predicate types (via `assert` checks and more).

Signed-off-by: Nike Okoronkwo <[email protected]>
@nikeokoronkwo nikeokoronkwo requested a review from srujzs September 9, 2025 14:21
@nikeokoronkwo nikeokoronkwo merged commit 25a0b5b into dart-lang:main Sep 14, 2025
16 of 18 checks passed
@nikeokoronkwo nikeokoronkwo deleted the interop/predicate-conditional branch September 14, 2025 05:03
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Sep 15, 2025
Revisions updated by `dart tools/rev_sdk_deps.dart`.

tools (https://github.com/dart-lang/tools/compare/319be98..4254267):
  4254267d  2025-09-11  Devon Carew  Update gemini config.yaml (dart-lang/tools#2162)
  6cb8f0f7  2025-09-11  Devon Carew  Update README.md (dart-lang/tools#2161)

web (https://github.com/dart-lang/web/compare/e2daa3a..25a0b5b):
  25a0b5b  2025-09-14  Nikechukwu  [interop] Add support for Conditional and Predicate Types (dart-lang/web#468)

Change-Id: I067ce2b7b48b2f57c145d49e2dad2dd2653ffb82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449581
Auto-Submit: Devon Carew <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
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.

Interop Gen: Support Conditional Types Interop Gen: Support Predicate Types
2 participants