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

Eliminate use of 'as' casts #524

Merged
merged 1 commit into from
Nov 3, 2019
Merged

Eliminate use of 'as' casts #524

merged 1 commit into from
Nov 3, 2019

Conversation

cbracken
Copy link
Member

@cbracken cbracken commented Nov 2, 2019

Enables the avoid_as lint.

@cbracken cbracken requested a review from yjbanov November 2, 2019 23:48
@googlebot googlebot added the cla: yes @googlebot is happy with the CLA status of this PR label Nov 2, 2019
@cbracken
Copy link
Member Author

cbracken commented Nov 2, 2019

This is PR 3 of 44.

@a14n
Copy link
Collaborator

a14n commented Nov 3, 2019

This lint might be deprecated in the future. See dart-lang/sdk#57894

@cbracken
Copy link
Member Author

cbracken commented Nov 3, 2019

Good to know. In general, I think this is still a worthwhile patch for the time being. None of these casts are required under Dart 2's type system. The one case I'm a little disappointed about is having to apply De Morgan's law to the conditional in stream_buffer.dart. It still reads fine, I guess.

@cbracken cbracken requested a review from a14n November 3, 2019 20:56
Also enables the avoid_as lint.
} else {
ret[follower] = chunk;
}
follower += subsize;
_offset += subsize;
_counter -= subsize;
leftToRead -= subsize;
if (chunk is! List || _offset >= (chunk as List).length) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we file a bug about is! not promoting to List here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@pq do you know if there's a bug on file for this already for the analyzer? I did a quick search on "is! infer type"... guessing this must already exist though :)

Copy link

Choose a reason for hiding this comment

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

I'm not sure if this is being tracked anywhere. It's possible this will get better w/ the type work for NNBD. @stereotype441: do you happen to know?

@cbracken cbracken merged commit 5753c4d into google:master Nov 3, 2019
@cbracken cbracken deleted the as_casts branch November 3, 2019 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes @googlebot is happy with the CLA status of this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants