-
Notifications
You must be signed in to change notification settings - Fork 28.5k
[pigeon] re-enable "treat warnings as errors" #126006
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
Comments
You enable warnings as errors for the unit test code itself in that PR. The plugin, which contains the generated code, already had that setting enabled, and wasn't reverted. |
updated. thx for clarification. |
…t test (#3901) `as [Any?]` here is actually not a "cast", but a "type annotation". An equivalent fix can be: ``` let arg: [Any?] = [nil] let inputEncoded = binaryMessenger.codec.encode(arg) ``` Fixes ``` heterogeneous collection literal could only be inferred to '[Any?]'; add explicit type annotation if this is intentional ``` Which was introduced in #3889 and later got reverted. See flutter/flutter#126006 for more details about some interesting research on this warning. *List which issues are fixed by this PR. You must list at least one issue.* Fixes flutter/flutter#126006 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
…t test (flutter#3901) `as [Any?]` here is actually not a "cast", but a "type annotation". An equivalent fix can be: ``` let arg: [Any?] = [nil] let inputEncoded = binaryMessenger.codec.encode(arg) ``` Fixes ``` heterogeneous collection literal could only be inferred to '[Any?]'; add explicit type annotation if this is intentional ``` Which was introduced in flutter#3889 and later got reverted. See flutter/flutter#126006 for more details about some interesting research on this warning. *List which issues are fixed by this PR. You must list at least one issue.* Fixes flutter/flutter#126006 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
Is there an existing issue for this?
Use case
We enabled "treat warnings as errors" for Swift pigeon's unit test in this PR, which got reverted, because our recent migration to Xcode 14.3 that introduced a new warning about type inference for "Any collection".
Background
The original diagnosis was introduced in swiftlang/swift@1d21b4e, which checks against type inference for heterogeneous collection:
The fix is simply to add type annotation:
This is reasonable diagnosis, since the heterogenous collection loses the concrete type info for the elements, so we need to explicitly indicate this is indeed what we want.
Though for (2), it could use better error message - it's not exactly a "heterogeneous" collection. But anyways, this diagnosis is basically saying, if a collection can only be inferred to [Any] or [Any?] (either heterogeneous collection or [nil]), you have to explicitly tell compiler this is indeed what you want.
Changes in Xcode 14.3 / Swift 5.8
Before Swift 5.8, when passing a literal into a function, the type annotation requirement is considered as satisfied:
This was fine, because the argument explicitly indicate that we want
[Any?]
type, hence no warnings or errors. However, in Swift 5.8, the above will trigger the same diagnosis (tho as a warning not an error).This change seems to be introduced by mistake, and already reverted in main branch and will be in Swift 5.9, so possibly Xcode
14.3.1
or14.4
.Proposal
The fix should be easy:
or:
The text was updated successfully, but these errors were encountered: