swiftlang/swift

Incorrect fix-it for static member access on instance

Offen

#85.157 geöffnet am 27.10.2025

 (2 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Swift (10.719 Forks)batch import
compilerdiagnostics qualityfix-itsgenericsgood first issueopaque parameter typesstatic declarationstype checker

Repository-Metriken

Stars
 (69.989 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 8T 17h) (510 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide