Skip to content

Ignoring library models return nullability on first-party code. - #446

Merged
lazaroclapp merged 2 commits into
masterfrom
lazaro_repro_nullness_check_confusion
Feb 23, 2021
Merged

lazaroclapp merged 2 commits into
masterfrom
lazaro_repro_nullness_check_confusion

Conversation

@lazaroclapp

Copy link
Copy Markdown
Contributor

By definition, library models are designed to handle third-party
libraries. However, as currently implemented, a library model
indicating an @Nullable return will apply to all subtypes of
the type in the model, including those in first-party code.
This change fixes that, ignoring library models information
whenever code is marked as unannotated.

See #445 for a discussion.

Generally, the principle behind this is that a method in
"annotated" code without an @Nullable annotation should
never magically just be considered to return @Nullable
implicitly, which is what the current/previous behavior
regarding library models did.

@lazaroclapp

Copy link
Copy Markdown
Contributor Author

Not to be landed yet, running internal tests.

@coveralls

coveralls commented Feb 19, 2021 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build #478

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 89.158%

Totals Coverage Status
Change from base Build #477: 0.01%
Covered Lines: 3462
Relevant Lines: 3883

💛 - Coveralls

@msridhar msridhar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, one suggestion on tests

" NonNullGetMessage(final String message) {",
" super(message);",
" }",
" @Override",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to write a test that we report an error when there is an override of getMessage() with no annotations and it returns null?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

By definition, library models are designed to handle third-party
libraries. However, as currently implemented, a library model
indicating an `@Nullable` return will apply to all subtypes of
the type in the model, including those in first-party code.
This change fixes that, ignoring library models information
whenever code is marked as unannotated.

See #445 for a discussion.

Generally, the principle behind this is that a method in
"annotated" code without an `@Nullable` annotation should
never magically just be considered to return `@Nullable`
implicitly, which is what the current/previous behavior
regarding library models did.
@lazaroclapp
lazaroclapp force-pushed the lazaro_repro_nullness_check_confusion branch from 0ecb41c to f0c8eb7 Compare February 22, 2021 23:10
@lazaroclapp
lazaroclapp merged commit 998ba05 into master Feb 23, 2021
@lazaroclapp
lazaroclapp deleted the lazaro_repro_nullness_check_confusion branch February 23, 2021 01:08
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