RFR: 8232933: Javac inferred type does not conform to equality constraint

Vicente Romero vromero at openjdk.org
Fri Oct 28 03:05:18 UTC 2022


When dealing with nested invocations it could be that the inference context of a nested invocation is propagated to the inference context of the outer invocation. There are occasions when the propagated inference context can be minimized if some of its inference variables are deemed redundant. This is an optimization that is done in order to speed up the type inference algo which can take a while if the number of variables to be reduced is large. Of course by removing some variables from an inference context we have an inherent risk of cutting too much and not being able to produce the same results compared to not minimizing it. My understanding is that this bug shows one of those cases in which an inference context has been reduced too much.

The proposed solution is not to minimize an inference context if at least one of its inference variables is a capture type. The reason is because when capture types are present, some bounds are wildcards which could be captured again generating new capture types etc., this could make impossible to prove that some constraints hold for an inference context, thus making the compiler wrongly reject correct code.

TIA

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

Commit messages:
 - 8232933: Javac inferred type does not conform to equality constraint

Changes: https://git.openjdk.org/jdk/pull/10897/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=10897&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8232933
  Stats: 60 lines in 2 files changed: 60 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/10897.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/10897/head:pull/10897

PR: https://git.openjdk.org/jdk/pull/10897


More information about the compiler-dev mailing list