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

implicit-casts:false on flutter_tools/lib #44447

Merged
merged 5 commits into from Nov 19, 2019

Conversation

a14n
Copy link
Contributor

@a14n a14n commented Nov 8, 2019

Description

Make the changes in flutter_tools/lib to prepare implicit-casts: false before NNBD

Related Issues

None

Tests

None because it's a refactoring.

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 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

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@fluttergithubbot
Copy link
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.

@fluttergithubbot fluttergithubbot added the tool Affects the "flutter" command-line tool. See also t: labels. label Nov 8, 2019
@a14n a14n force-pushed the implicit-casts-false-tools-lib branch from 3318534 to e43fec3 Compare November 8, 2019 21:39
@@ -99,9 +99,9 @@ Future<T> asyncGuard<T>(
completer.completeError(e, s);
return;
}
if (onError is _BinaryOnError) {
if (onError is _BinaryOnError<T>) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this should probably be _BinaryOnError<Null> and _UnaryOnError<Null>, the T there is unrelated to the overall value. @zanderso

Copy link
Contributor Author

Choose a reason for hiding this comment

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

onError is used to complete a Completer<T> so I think _BinaryOnError<T> is the right type to check here.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh yes you're right!

Copy link
Member

Choose a reason for hiding this comment

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

Yup, looks right to me.

@@ -477,7 +477,7 @@ class _BuildInstance {
if (results.any((bool result) => !result)) {
return false;
}
final AsyncMemoizer<bool> memoizer = pending[node.target.name] ??= AsyncMemoizer<bool>();
final AsyncMemoizer<bool> memoizer = (pending[node.target.name] ??= AsyncMemoizer<bool>()) as AsyncMemoizer<bool>;
Copy link
Member

Choose a reason for hiding this comment

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

This is a mistake in the type of pending above, it should take an AsyncMemoizer<bool> so it doesn't require a cast. Not necessary to fix in this PR, but otherwise please file an issue and assign to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the upcoming commit (rebase on master to remove conflicts)

@Hixie
Copy link
Contributor

Hixie commented Nov 11, 2019

cc @zanderso

@a14n a14n force-pushed the implicit-casts-false-tools-lib branch from e43fec3 to 5421b93 Compare November 11, 2019 21:16
@@ -367,13 +366,14 @@ class AndroidDevice extends Device {

@override
Future<bool> isLatestBuildInstalled(ApplicationPackage app) async {
Copy link
Member

Choose a reason for hiding this comment

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

Can the formal here be declared as @covariant AndroidApk app here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return installedSha1.isNotEmpty && installedSha1 == _getSourceSha1(app);
final AndroidApk apk = app as AndroidApk;
final String installedSha1 = await _getDeviceApkSha1(apk);
return installedSha1.isNotEmpty && installedSha1 == _getSourceSha1(apk);
}

@override
Future<bool> installApp(ApplicationPackage app) async {
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

final bool traceStartup = platformArgs['trace-startup'] ?? false;
final AndroidApk apk = package;
final bool traceStartup = platformArgs['trace-startup'] as bool ?? false;
final AndroidApk apk = package as AndroidApk;
Copy link
Member

Choose a reason for hiding this comment

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

Ditto for the package formal above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -282,7 +282,7 @@ Future<void> buildGradleApp({
command.add('-q');
}
if (artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = artifacts;
final LocalEngineArtifacts localEngineArtifacts = artifacts as LocalEngineArtifacts;
Copy link
Member

Choose a reason for hiding this comment

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

Since this one is under an is check, is it still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. artifacts is global getter and type promotion doesn't work.

@@ -520,7 +520,7 @@ Future<void> buildGradleAar({
command.add('-Ptarget-platform=$targetPlatforms');
}
if (artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = artifacts;
final LocalEngineArtifacts localEngineArtifacts = artifacts as LocalEngineArtifacts;
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. artifacts is global getter and type promotion doesn't work.

@@ -23,7 +23,7 @@ export FLUTTER_TARGET=$target
export PROJECT_DIR=${linuxProject.project.directory.path}
''');
if (artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = artifacts;
final LocalEngineArtifacts localEngineArtifacts = artifacts as LocalEngineArtifacts;
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@@ -309,13 +309,13 @@ class CocoaPods {
);
status.stop();
if (logger.isVerbose || result.exitCode != 0) {
if (result.stdout.isNotEmpty) {
if ((result.stdout as String).isNotEmpty) {
Copy link
Member

Choose a reason for hiding this comment

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

Consider making locals instead of copying the as expressions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -168,23 +168,23 @@ class Plugin {
static List<String> _validateMultiPlatformYaml(YamlMap yaml) {
final List<String> errors = <String>[];
if (yaml.containsKey(AndroidPlugin.kConfigKey) &&
!AndroidPlugin.validate(yaml[AndroidPlugin.kConfigKey])) {
!AndroidPlugin.validate(yaml[AndroidPlugin.kConfigKey] as YamlMap)) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be:

(yaml[AndroidPlugin.kConfigKey] is! YamlMap ||
 !AndroidPlugin.validate(yaml[AndroidPlugin.kConfigKey] as YamlMap))

Here and below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the function to introduce local function that do the check

final bool trackWidgetCreation = argParser.options.containsKey('track-widget-creation')
? argResults['track-widget-creation']
: false;
final bool trackWidgetCreation = argParser.options.containsKey('track-widget-creation') && argResults['track-widget-creation'] as bool;
Copy link
Member

Choose a reason for hiding this comment

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

I think this would be more readable as:

final bool trackWidgetCreation = argParser.options.containsKey('track-widget-creation') &&
                                 argResults['track-widget-creation'] as bool;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Splitted

@@ -27,7 +27,7 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {S
environment['FLUTTER_TARGET'] = target;
}
if (artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = artifacts;
final LocalEngineArtifacts localEngineArtifacts = artifacts as LocalEngineArtifacts;
Copy link
Member

Choose a reason for hiding this comment

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

ditto.

@a14n a14n force-pushed the implicit-casts-false-tools-lib branch from acc19cf to 722da4f Compare November 13, 2019 21:35
@a14n
Copy link
Contributor Author

a14n commented Nov 15, 2019

@zanderso PTAL

Copy link
Contributor Author

@a14n a14n left a comment

Choose a reason for hiding this comment

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

PTAL

@@ -251,7 +251,7 @@ class Uuid {
/// Given a data structure which is a Map of String to dynamic values, return
/// the same structure (`Map<String, dynamic>`) with the correct runtime types.
Map<String, dynamic> castStringKeyedMap(dynamic untyped) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -72,7 +72,7 @@ class AnalyzeCommand extends FlutterCommand {
@override
bool get shouldRunPub {
// If they're not analyzing the current project.
if (!argResults['current-package']) {
if (!(argResults['current-package'] as bool)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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 and thanks so much for doing this!

@a14n a14n merged commit adc7351 into flutter:master Nov 19, 2019
@a14n a14n deleted the implicit-casts-false-tools-lib branch November 19, 2019 06:57
@a14n a14n mentioned this pull request Nov 19, 2019
9 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants