Skip to content

Adds Compiler Warning to useless @Inject #889

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

Closed
wants to merge 1 commit into from

Conversation

SentryMan
Copy link
Collaborator

Now will warn when the @inject annotation is not needed

@SentryMan SentryMan added this to the 12.0 milestone Aug 22, 2025
@SentryMan SentryMan self-assigned this Aug 22, 2025
@SentryMan SentryMan added the enhancement New feature or request label Aug 22, 2025
Now will warn when the `@inject` annotation is not needed
@rbygrave
Copy link
Contributor

I don't understand the motiivation. Some people use @Inject on a constructor just to be more explicit and that would now be a warning?

What was the motivation for this?

@SentryMan
Copy link
Collaborator Author

Some people use @Inject on a constructor just to be more explicit and that would now be a warning?

It does not affect anything, so to me it's a useless addition. Even so, if you don't like it that's that (I don't care about this that much)

@SentryMan SentryMan closed this Aug 24, 2025
@rbygrave
Copy link
Contributor

Hmm, yeah there are those cases of (A) Necessary for multiple constructors case and (B) As documentation to assist people reading the code with their mental model of what is going on.

So I don't see it as harmful per se and I do think there are people who like to include it even when it's unnecessary for the documentation / learning / mental model type reasons. So yes at this stage I don't think we should actively discourage that with a compiler warning.

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

Successfully merging this pull request may close these issues.

2 participants