[SR-11412] Offer to make a type conform to protocols when a type mismatch occurs between a concrete type and generic parameter #53813
Labels
compiler
The Swift compiler in itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
task
Additional Detail from JIRA
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.The text was updated successfully, but these errors were encountered: