Skip to content
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

Correctly handle nullable type arguments in a number of APIs #711

Merged

Conversation

kevmoo
Copy link
Collaborator

@kevmoo kevmoo commented Nov 15, 2022

No description provided.

@@ -151,7 +151,7 @@ class HashBiMap<K, V> implements BiMap<K, V> {
@override
void updateAll(V Function(K key, V value) update) {
for (final key in keys) {
_add(key, update(key, _map[key]!), true);
_add(key, update(key, _map[key] as V), true);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handles the nullable V case correctly!

This could also iterate over entries to avoid the as check...

@@ -290,7 +290,7 @@ class LinkedLruHashMap<K, V> implements LruMap<K, V> {
V update(K key, V Function(V value) update, {V Function()? ifAbsent}) {
V newValue;
if (containsKey(key)) {
newValue = update(this[key]!);
newValue = update(this[key] as V);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No way around this, if I understand things correctly

@kevmoo kevmoo changed the title wip Correctly handle nullable type arguments in a number of APIs Nov 16, 2022
@@ -23,7 +23,7 @@ import 'dart:collection';
/// With the introduction of non-null by default in Dart SDK 2.12, developers
/// should avoid adding more uses of this type. Existing users should migrate
/// away from the `Optional` type to types marked nullable: `T?`.
class Optional<T> extends IterableBase<T> {
class Optional<T extends Object> extends IterableBase<T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably breaking, but if you can pull this through, hats off to you!

@kevmoo kevmoo merged commit 2f342a8 into google:master Nov 16, 2022
@kevmoo kevmoo deleted the null_check_on_nullable_type_parameter_fix branch November 16, 2022 03:38
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.

None yet

2 participants