-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[5.8] Collection literal inferred as Any when function type argument is Any #63982
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
The type of dictionary is inferred to |
I'm not sure how I feel about this myself, on one side this seems reasonable because collection is indeed heterogeneous but on other other hand we could consider parameter to be an explicit type annotation as well. |
yea that's what I was expecting |
After looking at 1d21b4e, which introduced this diagnostic, I think I might have misinterpreted its purpose. I agree with Keith that whether the literal has a defaulted type should not matter if it gets type-erased anyway. On its turn, an erasure expression implies the presence of an explicit type annotation somewhere. |
Since upgrading to Xcode 14.3 I I get the following warning, which I think maybe related: My app uses Firestore and as many statements like below which are impacted by the new change: assetDocument.setData([
"alerts": [
"service": [
"end": Timestamp(date: newDate),
],
],
], merge: true) { err in
if let err = err {
print("Error updating document: \(err)")
}
} Does anyone know if this is a bug that will be fixed in the next release of Xcode or do I have to find a fix to the issue that does not break my app? |
Should the changes be reverted then, @AnthonyLatsis? |
Yes, I will see if there is anything useful worth keeping while there’s still time until 5.9 converges. Do you want me to fully revert it for upcoming 5.8 patches now? |
Let’s revert on main and 5.9. |
no recollection sorry |
With this code:
Swift 5.8 from Xcode 14.3 beta 2 warns that the collection is inferred as Any:
In this case I'm surprised to see this warning since the function it's being passed to explicitly takes
[String: Any]
, so it being inferred as Any seems expected and I don't think needs a warningThe text was updated successfully, but these errors were encountered: