RFR: 8244681: Add a warning for possibly lossy conversion in compound assignments [v4]

Adam Sotona asotona at openjdk.java.net
Wed May 11 13:41:30 UTC 2022


> Please review this patch adding new lint option, **lossy-conversions**, to javac to warn about type casts in compound assignments with possible lossy conversions.
> 
> The new lint warning is shown if the type of the right-hand operand of a compound assignment is not assignment compatible with the type of the variable.
> 
> The implementation of the warning is based on similar check performed to emit "possible lossy conversion" compilation error for simple assignments. 
> 
> Proposed patch also include complex matrix-style test with positive and negative test cases of lossy conversions in compound assignments.
> 
> Proposed patch also disables this new lint option in all affected JDK modules and libraries to allow smooth JDK build. Individual cases to address possibly lossy conversions warnings in JDK are already addressed in a separate umbrella issue and its sub-tasks.
> 
> Thanks for your review,
> Adam

Adam Sotona has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:

 - Merge branch 'openjdk:master' into JDK-8244681
 - 8244681: Add a warning for possibly lossy conversion in compound assignments
   recommended correction of the warning description
 - 8244681: Add a warning for possibly lossy conversion in compound assignments
   recommended correction of the warning wording
   fixed typo in test method name
 - Merge branch 'openjdk:master' into JDK-8244681
 - 8244681: Add a warning for possibly lossy conversion in compound assignments
   jdk.internal.le make patch to disable warnings
 - 8244681: Add a warning for possibly lossy conversion in compound assignments

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/8599/files
  - new: https://git.openjdk.java.net/jdk/pull/8599/files/f0729396..a59dfa4f

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=8599&range=03
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=8599&range=02-03

  Stats: 9179 lines in 255 files changed: 5253 ins; 2422 del; 1504 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8599.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8599/head:pull/8599

PR: https://git.openjdk.java.net/jdk/pull/8599


More information about the compiler-dev mailing list