-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of ImplementationexistentialsFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesfix-itsFeature: diagnostic fix-itsFeature: diagnostic fix-itsgenericsFeature: generic declarations and typesFeature: generic declarations and typesgood first issueGood for newcomersGood for newcomersopaque typesFeature → types: opaque typesFeature → types: opaque typesswift 5.9type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistypesFeature: typesFeature: types
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
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of ImplementationexistentialsFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesfix-itsFeature: diagnostic fix-itsFeature: diagnostic fix-itsgenericsFeature: generic declarations and typesFeature: generic declarations and typesgood first issueGood for newcomersGood for newcomersopaque typesFeature → types: opaque typesFeature → types: opaque typesswift 5.9type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistypesFeature: typesFeature: types