Document known issue for propertyTypes rule with static factory methods on namespace types (#2449)

Co-authored-by: calda <1811727+calda@users.noreply.github.com>
This commit is contained in:
Copilot
2026-03-14 19:54:29 -07:00
committed by GitHub
parent 4cf685fd80
commit 4d992e2464
+2
View File
@@ -1086,6 +1086,8 @@ Known issues
* The `propertyTypes` rule can cause a build failure in cases like `let foo = Foo.bar` where the value is a static member that doesn't return the same time. For example, `let foo: Foo = .bar` would be invalid if the `bar` property was defined as `static var bar: Bar`. As a workaround you can write the name of the type explicitly, like `let foo: Bar = Foo.bar`, or exclude the type name and/or property name with `--preserve-symbols Bar,bar,etc`.
* The `propertyTypes` rule can cause a build failure in cases like `let value = Tools.makeString()` where `Tools` is used as a namespace (e.g. a caseless enum) and `makeString()` is a static factory method that returns a different type (e.g. `String`). The rule converts this to `let value: Tools = .makeString()`, which fails to compile. As a workaround you can write the type explicitly, like `let value: String = Tools.makeString()`, or exclude the type name and/or property name with `--preserve-symbols Tools,makeString,etc`, or use `// swiftformat:disable:next propertyTypes`.
* The `redundantEquatable` rule may incorrectly remove a `==` implementation that intentionally overrides a default `==` provided by another protocol. For example, `Strideable` provides a default `==` implementation derived from `distance(to:)`, and a type may override it with a custom `==`. SwiftFormat handles this case when the `Strideable` conformance is defined in the same file, but it cannot detect conformances in a different file, nor default `==` implementations provided by other protocols. As a workaround you can use the `// swiftformat:disable:next redundantEquatable` comment directive to disable the rule for the affected type (or just disable the `redundantEquatable` rule completely).