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

Vicente Romero vromero at openjdk.org
Tue Nov 1 19:15:06 UTC 2022


On Tue, 1 Nov 2022 10:29:17 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> The fix seems ok, if perhaps a bit too aggressive. Probably the problem comes from the fact that we should never treat captured inference variables as "regular" inference variables - so the minimization algorithm should treat them as black boxes and try not to do much with them. Of course bailing out if any capture is spotted is also an ok approach. It would be interesting to understand if this patch significantly alter the performance of the compiler in more common use cases.

Thanks for the review, some comments, I'm not sure if treating captured types as a black box could help. I assume you mean: if there are captured types just add them to the minimal set. But at least in this particular case this doesn't help. Here we have the following situation:

- there is an inference variable `A`, using same variable name as in the test case, who's undetVar has an equal bound linking it to the captured type
- so even if we determine that the captured type should be included in the minimal set, `A` won't ever be considered as it is not a bound of the captured type but the other way around

so we are back to square 1. We could define a more complex heuristic here to fit this case kind of saying OK if there are captured types, add them to the minimal set, along with any other variable equal to it. But I'm not sure if this will just fix this issue but not a similar one down the road. This is why I went for the all or nothing solution. Also, I think we are facing here a correctness issue so evaluating if the performance is hit or not, IMO is secondary if the correctness issue is unsolved.

PS. I mean correctness of the type inference algo

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

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


More information about the compiler-dev mailing list