Skip to content
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

[SR-9040] Suggestion when overriding implictly unwrapped optional does not suggest making parameter implictly unwrapped #51543

Open
JosephDuffy opened this issue Oct 18, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers

Comments

@JosephDuffy
Copy link

Previous ID SR-9040
Radar None
Original Reporter @JosephDuffy
Type Bug
Environment

Apple Swift version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1)
Target: x86_64-apple-darwin18.0.0

Additional Detail from JIRA
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![]( (if it's not, sorry))

@belkadan
Copy link
Contributor

Hm. I'm not sure that the parent method using ! implies that you want to use ! in your own implementation. We could have both fixes, but that might just confuse the matter. @rudkx, @xedin, what do you think?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants