[SR-9040] Suggestion when overriding implictly unwrapped optional does not suggest making parameter implictly unwrapped
#51,543 opened on Oct 18, 2018
Description
| Previous ID | SR-9040 |
| Radar | None |
| Original Reporter | @JosephDuffy |
| Type | Bug |
Apple Swift version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1)
Target: x86_64-apple-darwin18.0.0
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, DiagnosticsQoI, StarterBug |
| Assignee | None |
| Priority | Medium |
md5: 9b7c61d5cf17e72eb3e9d8e02cd54d9f
Issue Description:
When overriding a function that has an implicitly unwrapped optional parameter with a non-optional parameter, the fixit suggests adding ?, making the parameter optional.
I would expect this to offer adding !, along with ?, but I am not sure if this is classed as a bug, or an intentional change due to SE-0054.
Example code that produces the fixit:
class Foo {
func bar(_ bar: String!) {}
}
class FooSubclass: Foo {
override func bar(_ bar: String) {}
}
This produces the message: Cannot override instance method parameter of type 'String?' with non-optional type 'String', with an Insert '?' fix.
If this is classed as a bug I'd love to attempt to fix it)