RFR: bug: no warning shown for parameterized conversions [v4]

Vicente Romero vromero at openjdk.java.net
Wed Mar 9 16:53:38 UTC 2022


On Wed, 9 Mar 2022 14:27:12 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> this code is preserving the reference projection of a type var, if it was originally declared as a reference `T.ref`, instead of overriding it with its dual `T`. If the reference projection is not preserved then it leads to information loss. I haven't found another more reliable way
>
> I guess what I'm saying is that this method is designed to cause side-effects on the type it's called on. I believe that this method was originally only used in `Attr.visitTypeApply`, so that if you have a declaration like:
> 
> class Box<X> { ... }
> 
> And a type use like:
> 
> Box<? extends String>
> 
> When we hit `Attr.visitTypeApply`, we set the `bound` field of the `WildcardType` for `? extends String` to point to `X`. This field is then used in type containment tests.
> 
> The whole logic is dubious, and predates my time - but I have a feeling that depending on this obscure method to get the desired behavior is not correct.

OK I will do some more research here to see what alternatives we have, using this method is convenient as it is invoked whenever we do a mapping like for example from `Resolve::rawInstantiate` when we invoke `Types::memberType`, but I can try to find another way probably using a separate method to add the behavior I would like

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

PR: https://git.openjdk.java.net/valhalla/pull/666



More information about the valhalla-dev mailing list