swiftlang/swift
GitHub で見るDiagnostic for use of plain protocol name in type position should suggest `some` or `any`
Open
#68,284 opened on 2023年9月1日
bugcompilerdiagnostics qualityexistentialsfix-itsgenericsgood first issueopaque typesswift 5.9type checkertypes
Repository metrics
- Stars
- (69,989 stars)
- PR merge metrics
- (平均マージ 8d 17h) (30d で 510 merged PRs)
説明
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.