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

refactor context to be implicit-downcast safe #31622

Merged
merged 1 commit into from Apr 25, 2019

Conversation

jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented Apr 25, 2019

Description

Deprecate Context.operator[] and replace it with Context.get<T>() which uses the generic to look up the token. This allows us to use the T to perform an as cast to remove all context related implicit downcasts.

Old method is marked as deprecated to make it easier to migrate g3 usages of tool context.

Replaces #31031

Related Issues

#13815

Copy link
Member

@zanderso zanderso left a comment

Choose a reason for hiding this comment

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

lgtm

@jonahwilliams jonahwilliams merged commit 0acd3e6 into flutter:master Apr 25, 2019
@jonahwilliams jonahwilliams deleted the fix_context_casts branch April 25, 2019 22:51
if (value == null && _parent != null) {
value = _parent.get<T>();
}
return _unboxNull(value ?? _generateIfNecessary(T, _fallbacks)) as T;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can avoid the as here by saying:

T result = _unboxNull(value ?? _generateIfNecessary(T, _fallbacks));
return result;

(you can do the same above in AppContext get context)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants