You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This elicits a warning: "Treating a forced downcast to 'UIView' as optional will never produce 'nil'"
Now, I have to cast `arr[0]` down because it arrives as an array of Any. And I have to make `accessoryView` an Optional because I won't have its value until `viewDidLoad`. And I want to make it an implicitly unwrapped Optional because I intend to use it a lot and I don't want a bunch of extra punctuation in my code.
So it seems to me that this warning is too zealous; I'm being "punished" for doing something quite natural and called for by the situation.
I have no objection to changing `as!` to `as?` and silencing the warning. But it seems silly that I should have to, when I know for a fact that this Any is a UIView. Why should I be forced to express doubt about something of which I'm certain.
I also have no objection to wrapping the cast in parentheses to silence the warning.
So I'm not saying that there are no ways out of this warning. It's not a problem; I can silence the warning and move on. I'm just wondering whether the warning should be reconsidered; perhaps, in our zeal to recast IUOs as normal Optionals with special behavior, we may have tightened up the rules a little too far.
The text was updated successfully, but these errors were encountered:
Additional Detail from JIRA
md5: e4c4e6ffbd6471a88e824e734ac2dba8
is duplicated by:
relates to:
Issue Description:
I have this code in my view controller:
This elicits a warning: "Treating a forced downcast to 'UIView' as optional will never produce 'nil'"
Now, I have to cast `arr[0]` down because it arrives as an array of Any. And I have to make `accessoryView` an Optional because I won't have its value until `viewDidLoad`. And I want to make it an implicitly unwrapped Optional because I intend to use it a lot and I don't want a bunch of extra punctuation in my code.
So it seems to me that this warning is too zealous; I'm being "punished" for doing something quite natural and called for by the situation.
I have no objection to changing `as!` to `as?` and silencing the warning. But it seems silly that I should have to, when I know for a fact that this Any is a UIView. Why should I be forced to express doubt about something of which I'm certain.
I also have no objection to wrapping the cast in parentheses to silence the warning.
So I'm not saying that there are no ways out of this warning. It's not a problem; I can silence the warning and move on. I'm just wondering whether the warning should be reconsidered; perhaps, in our zeal to recast IUOs as normal Optionals with special behavior, we may have tightened up the rules a little too far.
The text was updated successfully, but these errors were encountered: