swiftlang/swift

Diagnostic for use of plain protocol name in type position should suggest `some` or `any`

开放

#68,284 创建于 2023年9月1日

 (19 条评论) (0 个反应) (1 位负责人)Swift (10,719 个派生)batch import
bugcompilerdiagnostics qualityexistentialsfix-itsgenericsgood first issueopaque typesswift 5.9type checkertypes

仓库指标

星标
 (69,989 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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.

贡献者指南