Skip to content

Replace no_grouping_extension with grouping_extension #6328

@rgoldberg

Description

@rgoldberg

New Issue Checklist

Feature or Enhancement Proposal

Replace no_grouping_extension with grouping_extension with an allow (maybe choose a different name like accept) option with values:

  • never: default, current behavior of no_grouping_extension
  • always: require that anything that can be moved from a type declaration to an extension be in an extension

And a conformance_extension option that also accepts:

  • default: allow if $allow == always; disallow if $allow == never (default)
  • allow: allow extension for conformance to a protocol (allows conformances on extension; allows conformances on type if $allow == never)
  • require: require extension for conformance to a protocol (allows conformances only on extension, not on type)

And a marker_conformance_extension option:

  • default: mimics $conformance_extension (default)
  • never: do not allow extension for conformance to a protocol without any members
  • allow: allow extension for conformance to a protocol without any members (allows conformances on extension; allows conformances on type if $allow == never)
  • require: require extension for conformance to a protocol without any members (allows conformances only on extension, not on type)

Maybe never should be the default for the above; if so, rename default as mimic_ conformance_extension.

And a conformance_extension_grouping option:

  • single: default, only one conformance per extension
  • multiple: allow multiple conformances per extension

(It doesn't make sense to me to allow some finite number of conformances per extension that is not 1, so I don't think that an integer value is appropriate here)

Maybe add an analyzer rule (I assume it can't be done in a non-analyzer rule) to require all members of a conformance extension to be relevant to the protocol, with an allow_helpers option that takes a visibility keyword or none (defaulting to private) to allow extension members besides those directly implementing a conformance to be included in the conformance, as long as they are not more visible than the given visibility.

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