RFR: bug: no warning shown for parameterized conversions [v2]
Vicente Romero
vromero at openjdk.java.net
Tue Mar 8 14:42:29 UTC 2022
On Tue, 8 Mar 2022 12:18:26 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> > > I'm not too convinced by this fix. Using warnStack seems really a workaround, and, on top of my head, I can't think of other code doing this. IMHO, universal vars introduce a new relation between types: `isBoundedBy`. What you want here is, essentially, a form to do `isBoundedByUnchecked` which should do strict check, followed by a looser one (like isSubtypeUnchecked does). There are many ways to do this, but it feels that having a better separation between these different routines could be, in the long term, a simplifying move (even if, in the short term it will create some code duplication). Because then we can fix the callsites to use the relationship we think is correct, depending on the case.
> >
> >
> > I'm not sure that `isSubtype` / `isSubtypeUnchecked` is the right analogy here as in most cases we get to the place where the warning is being issue in this PR without going through `isBoundedBy`
>
> I got confused, sorry (too many type relations!). Looking at the code some more, it seems to me that what we want is to enhance `isSubtypeUnchecked`, right? E.g. `isSubtypeUnchecked` is already called in places where the compiler allows unchecked conversions. But we need to add a new kind of unchecked conversion, which requires some recursion (because isSubtypeUnchecked can go to containsType which then can go back to isSubtype - not unchecked!).
>
> So, it seems to me that the subtyping routine has to be parameterized by the kind of containment routine we want to use. In the normal case, we'd just use Types::containsType - but if we want to check for nested unchecked warnings, we need to have a version of Types::containsType that is more flexible.
>
> In other words, I think what we need is a Types::containsTypeUnchecked - which we can use as a parameter to the subtyping routine.
I will try this, I was going through other way, to untangle some of the type routines, the good thing is that I already have a separate containtType relation for the unchecked case so I will build from there
-------------
PR: https://git.openjdk.java.net/valhalla/pull/666
More information about the valhalla-dev
mailing list