RFR: addressing several issues in the implementation of universal tvars [v4]

ExE Boss duke at openjdk.java.net
Fri May 20 16:59:19 UTC 2022


On Fri, 20 May 2022 14:50:45 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Last review iteration found several issues in the current implementation, addressing them here
>
> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
> 
>   removing commented code

Maybe instead of repeated ternaries, this could use a helper method for the `boolean` to `IsConvertibleResult` conversion:

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 606:

> 604:         CONVERTIBLE,
> 605:         CONVERTIBLE_REF_PROJECTION,
> 606:         NOT_CONVERTIBLE

Suggestion:

        NOT_CONVERTIBLE;

        static IsConvertibleResult of(boolean isConvertible) {
            return convertible ?
                CONVERTIBLE :
                NOT_COVERTIBLE;
        }

        static IsConvertibleResult ofRefProjection(boolean isConvertible) {
            return convertible ?
                CONVERTIBLE_REF_PROJECTION :
                NOT_COVERTIBLE;
        }

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 651:

> 649:                     return IsConvertibleResult.CONVERTIBLE_REF_PROJECTION;
> 650:             }
> 651:             return result ? IsConvertibleResult.CONVERTIBLE : IsConvertibleResult.NOT_CONVERTIBLE;

Suggestion:

            return IsConvertibleResult.of(result);

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 671:

> 669:                     warn.warn(LintCategory.UNCHECKED);
> 670:                 }
> 671:                 return result ? IsConvertibleResult.CONVERTIBLE_REF_PROJECTION : IsConvertibleResult.NOT_CONVERTIBLE;

Suggestion:

                return IsConvertibleResult.ofRefProjection(result);

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 680:

> 678:                     isSubtype(t, boxedTypeOrType(s)) :
> 679:                     isSubtype(boxedTypeOrType(t), s);
> 680:             return result ? IsConvertibleResult.CONVERTIBLE : IsConvertibleResult.NOT_CONVERTIBLE;

Suggestion:

            return IsConvertibleResult.of(tUndet ?
                    isSubtype(t, boxedTypeOrType(s)) :
                    isSubtype(boxedTypeOrType(t), s));

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 686:

> 684:             ? isSubtype(boxedClass(t).type, s)
> 685:             : isSubtype(unboxedType(t), s);
> 686:         return result ? IsConvertibleResult.CONVERTIBLE : IsConvertibleResult.NOT_CONVERTIBLE;

Suggestion:

        return IsConvertibleResult.of(tPrimitive
            ? isSubtype(boxedClass(t).type, s)
            : isSubtype(unboxedType(t), s));

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

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



More information about the valhalla-dev mailing list