google / google/error-prone

Pointless cast warning

Open
#94 2 comments 0 reactions 0 assignees View on GitHub
migrated Priority-Low Status-Accepted Type-NewCheck
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

_[Original issue](https://code.google.com/p/error-prone/issues/detail?id=94) created by **drichter@google.com** on 2013-02-26 at 08:59 PM_

---

Casts degrade program readability, and ones that are not automatically removed by the JRE hurt performance.

Here's an example extracted from real code:

class A {}
class B : A {}

List<B> someList;

for (A a : someList) // Line 1
{ ... ((B)a) ... } // Line 2

Line 2 should trigger the warning, citing the needless up-cast on Line 1.

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.