[lworld] RFR: 8280382: [lworld] JCWithField AST node support should evolve to work with value classes [v2]
Aggelos Biboudis
duke at openjdk.java.net
Fri Jan 28 13:16:44 UTC 2022
On Fri, 28 Jan 2022 11:51:16 GMT, Srikanth Adayapalam <sadayapalam at openjdk.org> wrote:
>> It was only introduced only after changing the lines 608 and 609 above, so it feels related to this change:
>>
>>> https://github.com/openjdk/valhalla/pull/621/files/e0f302f20eacdbb796d03240b5b727ce053ed451#diff-244efd7111106b403c989b25a6d0c719dcb15d44892320cfdc6056a418defb21L608-L609
>
> But those lines need not change at all. The original code in com.sun.tools.javac.code.Types#isConvertible(com.sun.tools.javac.code.Type, com.sun.tools.javac.code.Type, com.sun.tools.javac.util.Warner) viz:
>
> boolean tValue = t.isPrimitiveClass();
> boolean sValue = s.isPrimitiveClass();
> if (tValue != sValue) {
> return tValue ?
> isSubtype(t.referenceProjection(), s) :
> !t.hasTag(BOT) && isSubtype(t, s.referenceProjection());
> }
>
> is necessitated by the fact that in the language model a primitive class is an island. Even though Point may be declared to be:
>
> primitive class Point extends Object {}
>
> asSuper(Point, Object) would return null meaning Point is not a subclass of Object. We bend over backwards maintaining this isolated world view of primitive classes to make it analogous to how int is not a subtype of Object, but is convertible to Integer which is a subtype of Object. Likewise Point is not a subtype of Object, but is convertible to Point.ref and Point.ref is a subtype of Object.
>
> So is Point convertible to Object ? Yes, not because it is a subtype of Object, but because it can be converted to Point.ref and Point.ref is a subtype of Object.
>
> This is the dance that is being done in the code above. This code should not and need not change at all for the present topic at hand.
You are right. I made it it work by rebuilding and reverting this change! Thanks for the detailed explanation as always 🙏🏻🙏🏻🙏🏻
-------------
PR: https://git.openjdk.java.net/valhalla/pull/621
More information about the valhalla-dev
mailing list