[
https://issues.apache.org/jira/browse/CALCITE-5131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17532661#comment-17532661
]
Julian Hyde commented on CALCITE-5131:
--------------------------------------
Yes, but be careful. In many cases those casts are there for a reason. For
example, in the last case you cite (ExpressionTest) the "(int) 3" is there for
uniformity:
{noformat}
new Object[] {
(byte) 1, (short) 2, (int) 3, (long) 4,
(float) 5, (double) 6, (char) 7, true, "string", null
}, {noformat}
It would be better to leave the cast in and tell your IDE to get over itself.
In the DefaultDirectedGraph case, the cast was added in the fix for
CALCITE-4199 (nullability annotations). I'm guessing that if you remove the
cast, ErrorProne or CheckerFramework will complain.
In other cases, the cast may not be necessary on one JDK version but will be
necessary on others (due to changes in rules for resolving overloads, or
handling generics or nullability).
I suggest that you don't apply the IDE's suggestions automatically. Apply each
one by hand, when you have determined that the IDE really is smarter than the
human who wrote the code. And check that your code works with all JDK versions
and linting tools before you submit.
> Remove redundant type cast
> --------------------------
>
> Key: CALCITE-5131
> URL: https://issues.apache.org/jira/browse/CALCITE-5131
> Project: Calcite
> Issue Type: Improvement
> Reporter: Chunwei Lei
> Assignee: Chunwei Lei
> Priority: Major
> Attachments: image-2022-05-05-11-03-26-735.png, index.html,
> script.js, styles.css
>
>
> There're a number of redundant type casts. I suggest removing them.
> !image-2022-05-05-11-03-26-735.png!
>
> What do you think? BTW, it seems the CheckStyle plugin doesn't provide such a
> check.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)