google / google/error-prone

Matchers.isSubtypeOf always matches literal null

Open
#1,397 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

> ATTENTION! Please read and follow:
> - if this is a _question_ about Error Prone, send it to error-prone-discuss@googlegroups.com
> - if this is a _bug_ or _feature request_, fill the form below as best as you can.

### Description of the problem / feature request:

`Matchers.isSubtypeOf` always matches literal null. This would be correct if we were validating that the value can be cast to the requested type, however literal null should not match isSubtypeOf in most cases.
It's arguable that it could be matched for types `Void` and `Object`.

### Feature requests: what underlying problem are you trying to solve with this feature?

Either return false for null in most cases, or provide javadoc describing the issue.

### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

isSubtypeOf check on any null literal.

### What version of Error Prone are you using?

2.3.3

### Have you found anything relevant by searching the web?

No, I don't believe this has been reported yet.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.