Skip to content

[pigeon] Enable warnings as errors for remaining languages #3317

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

Merged
merged 5 commits into from
Feb 28, 2023

Conversation

stuartmorgan-g
Copy link
Contributor

Enables warnings-as-errors for remaining languages: Kotlin, Java, and Objective-C (it was already on for Swift and C++), and fix the resulting violations.

Fixes flutter/flutter#59116

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

@stuartmorgan-g
Copy link
Contributor Author

I realized while fixing Kotlin warnings that it'll conflict with your change, so I'll reconcile once that's landed. It shouldn't change much, so this should still be fine to review.

@@ -180,12 +180,13 @@ class KotlinGenerator extends StructuredGenerator<KotlinOptions> {
final HostDatatype hostDatatype = _getHostDatatype(root, field);
String toWriteValue = '';
final String fieldName = field.name;
final String safeCall = field.type.isNullable ? '?' : '';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes warnings about unnecessary safe calls on non-nullable values.

@@ -458,7 +458,7 @@ class JavaGenerator extends StructuredGenerator<JavaOptions> {
'$returnType $output = channelReply == null ? null : ((Number) channelReply).longValue();');
} else {
indent.writeln(
'$returnType $output = ($returnType) channelReply;');
'$returnType $output = ${_cast('channelReply', javaType: returnType)};');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The cast changes in Java and Kotlin fix uncessary casts (foo as Any?, foo as? Any in Kotlin, (Object) foo in Java).

@@ -1,30 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
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 forgot to delete this file in my last consolidation; it's unused. I was getting warnings in my stale output copy and couldn't figure out why at first since the source file was still there.

(Also: you'll need to clean your generated files again before this lands if you haven't done so recently.)

@@ -61,7 +61,7 @@ public void asyncSuccess() {
(bytes) -> {
bytes.rewind();
@SuppressWarnings("unchecked")
ArrayList wrapped = (ArrayList) codec.decodeMessage(bytes);
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 had to fix a bunch of raw type warnings in our tests, and suppress a bunch of unchecked casts for most of the same lines.

@tarrinneal
Copy link
Contributor

you have angered the kotlin unit tests

@stuartmorgan-g
Copy link
Contributor Author

I was focused on iterating on all the native tests and forgot to run the Dart unit tests. It was just an expectation that needed to be updated (based on the exact output of the wrapped code).

@stuartmorgan-g
Copy link
Contributor Author

Reconciled with #3284

@tarrinneal It seems like #3284 was incomplete for Kotlin, because I had fewer conflicts than I expected. I have several non-conflict areas where my new helper is being called with safeCast: foo.isNullable, which shouldn't be happening at all AFAIK.

@tarrinneal
Copy link
Contributor

Reconciled with #3284

@tarrinneal It seems like #3284 was incomplete for Kotlin, because I had fewer conflicts than I expected. I have several non-conflict areas where my new helper is being called with safeCast: foo.isNullable, which shouldn't be happening at all AFAIK.

I'll take a look once this is merged

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 28, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 28, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Feb 28, 2023

auto label is removed for flutter/packages, pr: 3317, due to - Please get at least one approved review if you are already a member or two member reviews if you are not a member before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@auto-submit
Copy link
Contributor

auto-submit bot commented Feb 28, 2023

auto label is removed for flutter/packages, pr: 3317, due to Validations Fail.

@stuartmorgan-g
Copy link
Contributor Author

Oops, I thought you'd reviewed. Bot checks for the win!

@tarrinneal
Copy link
Contributor

Oops, I thought you'd reviewed. Bot checks for the win!

I thought I had too, lol. Working on it now.

@tarrinneal
Copy link
Contributor

Reconciled with #3284

@tarrinneal It seems like #3284 was incomplete for Kotlin, because I had fewer conflicts than I expected. I have several non-conflict areas where my new helper is being called with safeCast: foo.isNullable, which shouldn't be happening at all AFAIK.

If this is something that should never happen, could we add an assert to enforce this?

@stuartmorgan-g
Copy link
Contributor Author

Reconciled with #3284
@tarrinneal It seems like #3284 was incomplete for Kotlin, because I had fewer conflicts than I expected. I have several non-conflict areas where my new helper is being called with safeCast: foo.isNullable, which shouldn't be happening at all AFAIK.

If this is something that should never happen, could we add an assert to enforce this?

We should just remove the flag (unless there is a use case for it that I missed). Which is what I thought I would do when I reconciled my PR with yours, and was thus surprised when I couldn't :)

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 28, 2023
@auto-submit auto-submit bot merged commit b98cd1f into flutter:main Feb 28, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 1, 2023
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
)

[pigeon] Enable warnings as errors for remaining languages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pigeon] make sure the generated code is free of analyzer warnings
2 participants