Description
Periphery produces contradictory diagnostics for a public @resultBuilder that is used as a parameter attribute in a public initializer.
Environment
Setup
// Module A
@resultBuilder
public struct ValidationErrorBuilder {
// ... buildBlock, buildOptional, etc.
}
public struct ValidationError {
public init(@ValidationErrorBuilder _ content: () -> [ValidationItem]) {
// ...
}
}
ValidationErrorBuilder is not referenced directly by name outside the module — consumers simply use the DSL syntax enabled by the @resultBuilder attribute on the public init. However, its public access level is required because it is used as a parameter attribute in a public initializer.
Problem
Same contradictory cycle as described in the constrained extension case:
-
Without // periphery:ignore — Periphery reports:
ValidationErrorBuilder is declared public is declared public, but not used outside of
This is a false positive because removing public would cause a compiler error: a @resultBuilder used as a parameter attribute in a public function/init must itself be public.
-
With // periphery:ignore — Periphery reports that the ignore annotation is unnecessary.
Expected Behavior
Periphery should recognize that a @resultBuilder type used as a parameter attribute in a public function or initializer requires public accessibility, and should not flag it as "redundant public".
Description
Periphery produces contradictory diagnostics for a
public@resultBuilderthat is used as a parameter attribute in apublicinitializer.Environment
Setup
ValidationErrorBuilderis not referenced directly by name outside the module — consumers simply use the DSL syntax enabled by the@resultBuilderattribute on thepublic init. However, itspublicaccess level is required because it is used as a parameter attribute in apublicinitializer.Problem
Same contradictory cycle as described in the constrained extension case:
Without
// periphery:ignore— Periphery reports:This is a false positive because removing
publicwould cause a compiler error: a@resultBuilderused as a parameter attribute in apublicfunction/init must itself bepublic.With
// periphery:ignore— Periphery reports that the ignore annotation is unnecessary.Expected Behavior
Periphery should recognize that a
@resultBuildertype used as a parameter attribute in apublicfunction or initializer requirespublicaccessibility, and should not flag it as "redundant public".