RFR: 8325859: potential information loss during type inference [v3]
Vicente Romero
vromero at openjdk.org
Mon May 12 10:42:50 UTC 2025
On Fri, 9 May 2025 14:18:32 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> The way this was designed, IIRC, was that if MIC is derived from IC, every time a variable is inferred in MIC, the resolution is forwarded to all the equivalent type variables in IC. If there's more type-variables in IC that are neither contained in MIC, nor equivalent to another var contained in MIC, it seems like an issue, as the minimization algo is not designed to work in this way.
yes I think this is an issue of the minimization algo. I mean there will always be at least one variable in MIC that won't be in IC and if MIC is asked to substitute that variable by its corresponding inference variable, then MIC won't be able to do it as it doesn't know how to map it and, potentially, some constraints won't be added to the inference variable. When we obtain MIC from IC we just don't know what queries we will do on MIC. The algo doesn't have this info.
I guess that there could be two ways to fix this:
- keeping links to the original inference contexts which will have more info, which is what this PR is doing
- trying to generate a more complete MIC gathering additional info
the second option seems like more complex as we could need some heuristics like type variables appearing in the same type, etc, and it could be harder to make sure that we get all the needed info. Also a more fluffy MIC would impact performance
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25011#issuecomment-2872007453
More information about the compiler-dev
mailing list