Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opt-in into API implementation #320

Open
qwwdfsad opened this issue Aug 15, 2022 · 3 comments
Open

Opt-in into API implementation #320

qwwdfsad opened this issue Aug 15, 2022 · 3 comments

Comments

@qwwdfsad
Copy link
Contributor

qwwdfsad commented Aug 15, 2022

This issue is for discussion of the proposal to introduce @SubclassOptInRequired annotation in Kotlin to provide a mechanism to require opt-in for API implementation only.

Proposal PR #319

@nreid260
Copy link

nreid260 commented Jan 6, 2023

This seems like it can be achieved today without adding new primitives:

interface DontSubclassMe {
  @MyExperimentalApi
  fun areYouSureYouWantToSubclassMe()

  fun theRealMethods()
}

@iTob191
Copy link

iTob191 commented Jun 23, 2023

Any reason why OptInRequired was used in the name instead of RequiresOptIn? The latter seems to be more in line with the existing annotation. Suggestions:

  • SubclassRequiresOptIn
  • RequiresOptInForSubclass
  • (RequiresSubclassOptIn)

The first two suggestions share the same term (RequiresOptIn) with the existing annotation which is beneficial for code completion and using the same term also helps to remember the name.

@ejller
Copy link
Contributor

ejller commented Jun 19, 2024

This seems like it can be achieved today without adding new primitives:

interface DontSubclassMe {
  @MyExperimentalApi
  fun areYouSureYouWantToSubclassMe()

  fun theRealMethods()
}

Unfortunately, current experimental/opt-in markers can’t cover all library use-cases. The main use-case for SubclassOptInRequired is when an interface is stable for use but unstable to implement because new methods could potentially be added to this interface.
For example:

Its behavior can’t be achieved using a simple experimental marker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants