swiftlang/swift

Incorrect fix-it for static member access on instance

Aperta

#85.157 aperta il 27 ott 2025

 (2 commenti) (0 reazioni) (1 assegnatario)Swift (10.719 fork)batch import
compilerdiagnostics qualityfix-itsgenericsgood first issueopaque parameter typesstatic declarationstype checker

Metriche repository

Star
 (69.989 stelle)
Metriche merge PR
 (Merge medio 8g 17h) (510 PR mergiate in 30 g)

Descrizione

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

Guida contributor