swiftlang/swift

Incorrect fix-it for static member access on instance

開放

#85,157 建立於 2025年10月27日

 (2 則留言) (0 個反應) (1 位負責人)Swift (10,719 個分叉)batch import
compilerdiagnostics qualityfix-itsgenericsgood first issueopaque parameter typesstatic declarationstype checker

倉庫指標

星標
 (69,989 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Description

In the following example the compiler offers to replace p with some P, which is obviously not going to work. The same applies to any P.

Reproduction

protocol P {
  static var x: Int {get}
}
func foo(p: some P) -> Int {
  p.x
}

Expected behavior

We should probably make it wrap the base in type(of:) instead.

Environment

Swift version 6.3-dev (1ae8ef0004e7405)

Additional information

No response

貢獻者指南