Skip to content

Allow restricting entire classes with @RestrictedApi #2087

@cushon

Description

@cushon

Originally requested in #1592

Adding support for restricting API for the entire type. RestrictedApi check currently only supports for annotating methods, with this change, it will be possible to annotate the class and make sure all the methods in that class will be restricted with given annotation configuration.

Before implementing this, we'd need to decide what the semantics of restricting the uses of a type should be. One interpretation is to disallow calls to methods in that type, as if all the methods were annotated with @RestrictedApi. Another interpretation is to try to prevent uses of the type in a more general way, e.g. if it's used as the type of a field, or if it's referenced in another way where the type may not even appear in source (e.g. the return type of foo() in x.foo().bar()).

If you're interested in this feature, it'd be helpful to share detail about use-cases you have in mind, and what behaviour you'd expect from annotating a type with @RestrictedApi.

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