Skip to content

Periphery Issue: Redundant public accessibility false positive #1111

@juicyfru1t

Description

@juicyfru1t

Description

Periphery produces contradictory diagnostics for a public class that is used in a constrained extension of a public protocol.

Environment

  • Periphery: 3.7.2

Setup

// Module A

public protocol MapViewMarkerModel { }

public class DefaultMapViewMarkerModel: MapViewMarkerModel {
    // ... properties
}

extension MapViewMarkerModel where Self == DefaultMapViewMarkerModel {
    public func ...
    // ... convenience API
}

DefaultMapViewMarkerModel is not referenced directly outside the module, but its public access level is required because it appears in the generic constraint of an extension on MapViewMarkerModel, containing public properties.

Problem

There is a no-win situation with Periphery diagnostics:

  1. Without // periphery:ignore — Periphery reports:

    DefaultMapViewMarkerModel is declared public is declared public, but not used outside of module

    This is a false positive because removing public would cause a compiler error: the class is used in a where Self == constraint on a public extension, so it must also be public.

  2. With // periphery:ignore — Periphery reports that the ignore annotation is unnecessary.

This creates a contradictory state where the diagnostic cannot be resolved by any means other than excluding the file entirely. Ignore worked fine in 3.2.0 version, but was false-positive.

Expected Behavior

Periphery should recognize that a type referenced in a generic constraint of an extension containing public properties (e.g., where Self == SomeType) requires public accessibility, and should not flag it as "redundant public".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions