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-11679] Incorrect fixit suggestion for init in CFType extension #54088

Closed
nicklockwood opened this issue Oct 29, 2019 · 6 comments
Closed
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

@nicklockwood
Copy link
Contributor

Previous ID SR-11679
Radar None
Original Reporter @nicklockwood
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug
Assignee alagos (JIRA)
Priority Medium

md5: 12d2b7a4d3ba982058d48bdb58177541

Issue Description:

Adding initializers to CFTypes via an extension is apparently not supported, but the compiler suggests this can be fixed by adding the `convenience` keyword (which doesn't work).

@belkadan
Copy link
Contributor

This error message comes from diag::designated_init_in_extension in TypeCheckDecl.cpp; we can have it emit a different message if the class is a CF type. The way to test for CF types is shown just above in the same method in order to emit the second diagnostic, diag::cfclass_convenience_init.

@swift-ci
Copy link
Collaborator

Comment by Alberto Lagos (JIRA)

Hi @belkadan, it ok if I take this ticket and try to fix it? I believe that it will be a good way to start contributing to swift.

@belkadan
Copy link
Contributor

Yep, welcome! Please ask me or @CodaFi if you have questions.

@swift-ci
Copy link
Collaborator

swift-ci commented Nov 1, 2019

Comment by Alberto Lagos (JIRA)

@belkadan Like you said, above where diag::designated_init_in_extension is emitted, I can determine if the Decl is of type CF:

classDecl->getForeignClassKind() == ClassDecl::ForeignKind::CFType

My solution basically implies duplication of code, is that ok?.

Another question is, where I find the test related to the TypeCheckDecl? (more concrete ```InitKindRequest```).

Thanks!

cc CodaFi (JIRA User)

@belkadan
Copy link
Contributor

belkadan commented Nov 1, 2019

I think it's okay to duplicate that check. You shouldn't have to duplicate much more, right? You'd emit the alternative diagnostic instead?

As for where to put the test case, I don't know offhand, but I'd search the test/ directory for the existing messages emitted by diag::designated_init_in_extension and diag::cfclass_convenience_init.

@swift-ci
Copy link
Collaborator

swift-ci commented Nov 1, 2019

Comment by Alberto Lagos (JIRA)

I just submit a PR #28015

Let me know anything.

Thanks @belkadan for your help!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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

3 participants