Integrated: 8310685: [lw5] adding support for null restricted types
Vicente Romero
vromero at openjdk.org
Mon Jun 26 17:58:35 UTC 2023
On Mon, 26 Jun 2023 09:26:41 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> initial support for null restricted types
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 1170:
>
>> 1168: * make sure that the caller really wants to warn
>> 1169: */
>> 1170: if (s.isNonNullable() && warnStack.head.pos() != null) {
>
> This is a bit odd. We are defining a type relationship - if "BOT" is not a subtype of T! that is fine, we should just return false. Giving an error seems a bit strange here (I don't think it is normal for subtyping to generate errors).
yep you are right
> src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java line 2128:
>
>> 2126: if (tree.lhs.type.isNonNullable()) {
>> 2127: code.emitop0(dup);
>> 2128: genNullCheck(tree.rhs);
>
> Should the null check always be generated even if we know that the RHS is non-nullable? (I'm not sure here)
I'm not sure either, I preferred to stay on the safe side. We can always revisit this later
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/872#discussion_r1242556817
PR Review Comment: https://git.openjdk.org/valhalla/pull/872#discussion_r1242555284
More information about the valhalla-dev
mailing list