-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Make AppContext immutable and race-free #15984
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
Conversation
| context.putIfAbsent(Usage, () => new DisabledUsage()); | ||
| return runner(args); | ||
| }); | ||
| T runInContext<T>( |
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.
I recommend making this return Future<T>.
This is because otherwise if you ever consider adding any async code here, and you create a Completer, you won't be able to complete it, because passing a Future to a Completer unwraps the future and causes a type error.
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.
Done
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.
Or perhaps FutureOr<T>?
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.
No, runner had to be made FutureOr<T>, but this now definitely returns Future<T>
| String toString() { | ||
| final StringBuffer buf = new StringBuffer('Dependency cycle detected: '); | ||
| buf.write(cycle.join(' -> ')); | ||
| return buf.toString(); |
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.
nit: this is the same as: => 'Dependency cycle detected: ${cycle.join(' -> ')}'
| }, | ||
| ); | ||
| expect(called, isTrue); | ||
| expect(value, 'child'); |
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.
Did you mean to put called = true into a parent generator? I can't tell which check shows that the parent was consulted.
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.
No, this just exists to make sure that context.run didn't skip the body entirely. I originally had a "parent consulted" check, but that can't work, because if the parent is consulted, it means it had a generator, so the fallback would never be consulted...
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.
Ah, got it. I was confused by the test description. I thought the test somehow tracked when the fallbacks are consulted relative to the parent.
| context.putIfAbsent(Usage, () => new DisabledUsage()); | ||
| return runner(args); | ||
| }); | ||
| T runInContext<T>( |
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.
Or perhaps FutureOr<T>?
| }, | ||
| ); | ||
| expect(called, isTrue); | ||
| expect(value, 'child'); |
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.
Ah, got it. I was confused by the test description. I thought the test somehow tracked when the fallbacks are consulted relative to the parent.
|
This mostly seems fine but I'm still a bit concerned that you sometimes run with a type that's a The problem with sometimes expecting a Also sometimes you don't type the call to |
|
This seems to have broken running flutter with local engine: Reason for the failure is that now we use |
It's required to be set before we detect local engine. Was broken by #15984
This updates AppContext per the recommendations in flutter#15352 Fixes flutter#15352
Follow-up comments to flutter#15984
It's required to be set before we detect local engine. Was broken by flutter#15984

This updates AppContext per the recommendations in #15352
Fixes #15352