realm / realm/SwiftLint

Emulate `protected` visiblity modifier on fields/functions

Open
#4,049 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

Swift has no protected modifier. It still is handly. Currently we just make it public and just agree to not use certain functions/fields.

This is obviously error prone. Best solution would be some sort of annotation, like this

class Foo {
   @Protected
   protected bar() {
      //
   }
}

and then linter would enforce not calling this outside of the class

Would that be possible?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name any files, tests, or entry points. Start by locating SwiftLint's rule and annotation-handling architecture, then determine whether a protected-visibility annotation and enforcement rule are feasible; done would require an agreed design and tests covering valid and invalid access.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.