Skip to content

replace runtimeType.toString()#48892

Merged
fluttergithubbot merged 1 commit intoflutter:masterfrom
a14n:runtimeType-toString
Jan 16, 2020
Merged

replace runtimeType.toString()#48892
fluttergithubbot merged 1 commit intoflutter:masterfrom
a14n:runtimeType-toString

Conversation

@a14n
Copy link
Copy Markdown
Contributor

@a14n a14n commented Jan 15, 2020

Description

follow up on #48607

Related Issues

#31695

Tests

None

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.

@fluttergithubbot fluttergithubbot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Jan 15, 2020
@fluttergithubbot
Copy link
Copy Markdown
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@a14n a14n requested a review from dnfield January 15, 2020 16:22
@a14n
Copy link
Copy Markdown
Contributor Author

a14n commented Jan 15, 2020

I made a lint available in https://github.com/a14n/linter/tree/avoid_runtimeType_toString that find some other places but I'm not sure if it make sense to replace them. WDYT?

$ bin/cache/dart-sdk/bin/dart ../../dart-lang/linter/bin/linter.dart --rules avoid_runtimeType_toString --packages packages/flutter/.packages packages/flutter/lib | grep 'lint'
/xxx/packages/flutter/lib/src/animation/listener_helpers.dart 130:69 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/animation/listener_helpers.dart 133:21 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/animation/listener_helpers.dart 199:76 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/animation/listener_helpers.dart 202:21 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/foundation/change_notifier.dart 212:77 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/foundation/change_notifier.dart 215:23 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/foundation/diagnostics.dart 1544:15 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart 206:27 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart 209:19 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart 215:36 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart 244:37 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart 252:49 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/widgets/framework.dart 1519:38 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/widgets/framework.dart 1520:20 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/widgets/framework.dart 1524:25 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/widgets/focus_manager.dart 1301:75 [lint] Avoid calling toString() on runtimeType.
/xxx/packages/flutter/lib/src/widgets/focus_manager.dart 1304:21 [lint] Avoid calling toString() on runtimeType.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This one is ok because it's part of an assertion.

Is there some way to make the lint recognize whether the call is within an assert or throw?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The lint does test if it's inside an assertion. I don't see assert in this case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah yes, I was imprecise. It should still be ok if it's part of a throw. At that point, we don't really care about performance as much anymore and having the real type information would be helpful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I reverted this change.

@a14n a14n force-pushed the runtimeType-toString branch from 663aa95 to ab2337f Compare January 15, 2020 19:48
Copy link
Copy Markdown
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@fluttergithubbot fluttergithubbot merged commit c195b77 into flutter:master Jan 16, 2020
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants