New check request: autoboxing on ternary operator
Open
- Dominant language
- Java
- Stars
- 7.2k
- Forks
- 820
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 50
Description
Imagine I have this method:
```java
Boolean returnABoolean()
```
and:
```java
boolean isEnabled = true;
Boolean myValue = isEnabled ? returnABoolean() : false;
```
This will crash if the `returnABoolean()` returns `null` because the [JLS says](https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.25.1):
> If the second and third operands are both of type Boolean, the conditional expression has type Boolean. **Otherwise, the conditional expression has type boolean.**
If ErrorProne could detect this it would be very helpful.
Contributor guide
Assessment
This issue has not been assessed yet.