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-11412] Offer to make a type conform to protocols when a type mismatch occurs between a concrete type and generic parameter #53813

Closed
jckarter opened this issue Sep 3, 2019 · 2 comments
Assignees
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation task

Comments

@jckarter
Copy link
Member

jckarter commented Sep 3, 2019

Previous ID SR-11412
Radar None
Original Reporter @jckarter
Type Task
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Task, DiagnosticsQoI
Assignee @theblixguy
Priority Medium

md5: 9c3965c8e75b831ca4b57e6f55ca261e

Issue Description:

https://twitter.com/0xced/status/1168966245821161472

If a function expects a protocol-typed argument, and the given argument doesn't conform to the protocols, then the compiler suggests force-casting to the protocol type, e.g. insert 'as! P & Q'. It is more likely that the user intends to make the type conform to those protocols. The compiler should instead offer to add conformances to the required protocols to the type.

@theblixguy
Copy link
Collaborator

PR: #27026

Seems to be able to handle basic cases like the one in the tweet at the moment.

@theblixguy
Copy link
Collaborator

Fixed on master. Please verify using the next available master snapshot.

@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
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation task
Projects
None yet
Development

No branches or pull requests

2 participants