Make AppContext immutable and race-free#15984
Make AppContext immutable and race-free#15984tvolkert merged 7 commits intoflutter:masterfrom tvolkert:context
Conversation
| context.putIfAbsent(Usage, () => new DisabledUsage()); | ||
| return runner(args); | ||
| }); | ||
| T runInContext<T>( |
There was a problem hiding this comment.
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.
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.
nit: this is the same as: => 'Dependency cycle detected: ${cycle.join(' -> ')}'
| }, | ||
| ); | ||
| expect(called, isTrue); | ||
| expect(value, 'child'); |
There was a problem hiding this comment.
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.
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.
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>( |
| }, | ||
| ); | ||
| expect(called, isTrue); | ||
| expect(value, 'child'); |
There was a problem hiding this comment.
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