RFR: 8289397: Fix warnings: Possible accidental assignment in place of a comparison. A condition expression should not be reduced to an assignment
Phil Race
prr at openjdk.org
Tue Jul 26 22:07:24 UTC 2022
On Tue, 26 Jul 2022 21:14:58 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
> - replaced with exact functional equivalent (in the presence of exceptions, for example)
This warning seems to be saying "the language has this feature that the designers thought useful, but I don't like it so
I'm going to complain".
I don't see the difference between
if (valid = res.validate(fctx)) {
and
if ((valid = res.validate(fctx)) == true) {
in both cases we are using the value returned by the assignment and if magically using it in ( X == true) instead of if (X)
makes the warning go away that is both artificial and clumsy.
how does now it know you didn't mean
if ((valid == res.validate(fctx)) == true) {
So I'd not make these changes. If someone (else) does then agree with them at least fix "if(" -> "if ("
-------------
PR: https://git.openjdk.org/jfx/pull/851
More information about the openjfx-dev
mailing list