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-7629] Wrong fixit when the type doesn't conform to a public protocol #50171

Open
swift-ci opened this issue May 8, 2018 · 9 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers

Comments

@swift-ci
Copy link
Contributor

swift-ci commented May 8, 2018

Previous ID SR-7629
Radar None
Original Reporter sriharims (JIRA User)
Type Bug
Status In Progress
Resolution
Environment

Xcode 9.3, Swift 4.1

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug
Assignee None
Priority Medium

md5: 54986872b23e84cdf4f86614e935c40e

Issue Description:

This is my code without the protocol conformance

public struct Numbers: OptionSet

{

public let rawValue: Int



static let one = Numbers(rawValue: 1)

static let two = Numbers(rawValue: 2)

}

The error message - " Initializer 'init(rawValue🙂' must be declared public because it matches a requirement in public protocol 'OptionSet' " is correct, but the fixit inserts 'public' after 'struct' like this -

public struct public Numbers: OptionSet

@belkadan
Copy link
Contributor

belkadan commented May 8, 2018

Good catch! Tagging as a Starter Bug, because I think this can be fixed by teaching swift::fixItAccess in MiscDiagnostics.cpp to not do anything if the declaration in question is implicit.

@swift-ci
Copy link
Contributor Author

swift-ci commented Jun 9, 2018

Comment by Naruki Chigira (JIRA)

I created PR.
This issue will occur when generated initializer is non public. I checked kind of initializer and disable wrong fixit.

@swift-ci
Copy link
Contributor Author

Comment by Naruki Chigira (JIRA)

@belkadan I'm glad you to check my PR when you have a time. Thanks!

@belkadan
Copy link
Contributor

Ah, I saw that Brent already started reviewing and was going to let him finish. I'll let him know!

@swift-ci
Copy link
Contributor Author

Comment by Naruki Chigira (JIRA)

I understood! Thank you for your response 🙂

@swift-ci
Copy link
Contributor Author

swift-ci commented Jan 4, 2019

Comment by Daniel Jalkut (JIRA)

I ran into this today and was also confused by it. I ended up finding https://bugs.swift.org/browse/SR-3003 where it seemed to be closed as fixed some time ago, but maybe the gist of that bug was actually slightly different.

@belkadan
Copy link
Contributor

belkadan commented Jan 7, 2019

Ah, hm. We ended up taking the PR listed above; do you think there's still more work to be done? (You can try with a master or 5.0 snapshot at https://swift.org/download/.)

@swift-ci
Copy link
Contributor Author

swift-ci commented Jan 7, 2019

Comment by Daniel Jalkut (JIRA)

I confirmed the 1/5 snapshot doesn't offer the problematic fix-it. Ideally I think there should be a fix-it offered to add the public initializer. The error is confusing because it complains about the publicity of an initialzer that is not present in the developer's code.

@swift-ci
Copy link
Contributor Author

Comment by Steffan Andrews (JIRA)

Issue persists in Swift 5.5.2

@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 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