-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dart][dart-dio] Add type information to oneOf and anyOf #20788
base: master
Are you sure you want to change the base?
Conversation
Unfortunately, the dart-dio generator seems to lack sufficient tests, so it's unclear whether it works correctly in all cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't this case just return OneOfDynamic to be backwards compatible?
typeIndex: oneOf.typeIndex, | ||
); | ||
} | ||
throw ArgumentError('Invalid number of types: ${oneOf.types.length}'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meant here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can maintain backward compatibility, but a simple replacement won't work.
If we simply return OneOfDynamic
, it will fail when casting to OneOfx
(OneOf{{oneOf.size}}
), resulting in an error.
A slightly more involved approach would be to introduce a flag for cases with seven or more oneof
values—if set to true
, it would use OneOfDynamic
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I never really liked the idea of fitting infinitely large oneof/anyof cases into a single variable
The approach I followed here #18970 is much cleaner, and is similar to what protobuf does
We will stop using OneOfDynamic and switch to OneOfx.
This will improve type safety.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming7.x.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)@jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)