This repository was archived by the owner on Aug 20, 2025. It is now read-only.
Add check for nullability mismatch.#149
Open
runningcode wants to merge 1 commit intoJakeWharton:masterfrom
Open
Add check for nullability mismatch.#149runningcode wants to merge 1 commit intoJakeWharton:masterfrom
runningcode wants to merge 1 commit intoJakeWharton:masterfrom
Conversation
TWiStErRob
reviewed
Jul 19, 2019
TWiStErRob
reviewed
Jul 19, 2019
|
|
||
| @Override | ||
| public @Nullable Object invoke(Object[] args) { | ||
| if (binding instanceof LinkedProvidesBinding) { |
Contributor
There was a problem hiding this comment.
@BindsInstance could also have @Nullable can't it?
Owner
There was a problem hiding this comment.
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.
Contributor
Author
|
Hmm, should we introduce |
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.
d97b3b6 to
51a9180
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.