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
Conversation
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. |
3318534
to
e43fec3
Compare
@@ -99,9 +99,9 @@ Future<T> asyncGuard<T>( | |||
completer.completeError(e, s); | |||
return; | |||
} | |||
if (onError is _BinaryOnError) { | |||
if (onError is _BinaryOnError<T>) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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>; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
cc @zanderso |
e43fec3
to
5421b93
Compare
@@ -367,13 +366,14 @@ class AndroidDevice extends Device { | |||
|
|||
@override | |||
Future<bool> isLatestBuildInstalled(ApplicationPackage app) async { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
acc19cf
to
722da4f
Compare
@zanderso PTAL |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this 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!
Description
Make the changes in
flutter_tools/lib
to prepareimplicit-casts: false
before NNBDRelated 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.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?