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

Add check for nullability mismatch. #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

runningcode
Copy link
Contributor

When there is a mismatch between the nullability of the binding and the
requestor, throw an exception.

This only works if the nullability annotations have runtime retention.

Looking for feedback to see if this is a reasonable approach and how/if we should make the error message better.

}

@Override
public @Nullable Object invoke(Object[] args) {
if (binding instanceof LinkedProvidesBinding) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BindsInstance could also have @Nullable can't it?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think there needs to be something like a isNullable on Binding until type annotations save us from this nonsense. And then anyone requesting a Binding will have to validate that the consumer can handle null.

@runningcode
Copy link
Contributor Author

runningcode commented Jul 21, 2019

Hmm, should we introduce DependencyRequest to dagger reflect?
I feel like it would add a good bit of runtime overhead to create one for each DepenencyRequest.

When there is a mismatch between the nullability of the binding and the
requestor, throw an exception.

This only works if the nullability annotations have runtime retention.
@runningcode runningcode force-pushed the no/checknullability branch from d97b3b6 to 51a9180 Compare July 21, 2019 20:57
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

Successfully merging this pull request may close these issues.

3 participants