Open
Description
The following code is invalid:
protocol P {
associatedtype A
}
func generic(value: P) {}
The compiler currently produces the error message Use of protocol 'P' as a type must be written 'any P'
with a fix-it to insert the any
keyword.
However, a different (and often better!) fix here is to use the some
keyword. The error message should be re-worded to prompt the programmer to consider any
or some
, and there should be two notes, each with a fix-it to insert any
or some
, respectively.
Metadata
Metadata
Assignees
Labels
A deviation from expected or documented behavior. Also: expected but undesirable behavior.The Swift compiler itselfBug: Diagnostics Quality of ImplementationFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesFeature: diagnostic fix-itsFeature: generic declarations and typesGood for newcomersFeature → types: opaque typesArea → compiler: Semantic analysisFeature: types