Skip to content

Commit 4edf86f

Browse files
Ilya Yanokcopybara-github
authored andcommitted
Change != null to is T to handle "double nullable" case
We use `dummyValueOrNull<T>`/`ifNotNull` combination to return a proper `Future<T>` when `T` is not known at compile time but a dummy value for `T` exists at run time, instead of falling back to creating a `FakeFuture` (that can't be `await`ed for example). This works fine unless `T` itself allows `null` (is nullable or `void`). In this case `dummyValueOrNull<T>` returns `null`, but it's a proper `T`, not a failure. This CL changes `ifNotNull` to check `is T` instead of `!= null` to handle this properly. PiperOrigin-RevId: 574437205
1 parent 47a5588 commit 4edf86f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/src/dummies.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,4 @@ void resetDummyBuilders() {
174174

175175
// Helper function.
176176
R? ifNotNull<T, R>(T? value, R Function(T) action) =>
177-
value != null ? action(value) : null;
177+
value is T ? action(value) : null;

0 commit comments

Comments
 (0)