Skip to content

[SR-11412] Offer to make a type conform to protocols when a type mismatch occurs between a concrete type and generic parameter #53813

@jckarter

Description

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

Metadata

Metadata

Assignees

Labels

compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementation

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions