[code-reflection] RFR: Unify common code of SwitchStatementOp and SwitchExpressionOp [v2]
Paul Sandoz
psandoz at openjdk.org
Tue Sep 10 01:26:08 UTC 2024
On Tue, 10 Sep 2024 01:20:00 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOp.java line 973:
>>
>>> 971: } else {
>>> 972: exit = b.block(resultType());
>>> 973: if (result() != null) { // i.e. resultType not void
>>
>> All operations in a built model have a result value, even if it's a void value. So this expression will always be true. Use a `this instanceof ...` test?
>
> I see. Or we can test if resultType isn't void
It cannot be:
/**
* Returns the operation's result, otherwise {@code null} if the operation is not assigned to a block.
*
* @return the operation's result, or {@code null} if not assigned to a block.
*/
public final Result result() {
return result;
}
The field is only null if the operation is not assigned (or bound) to a block, otherwise it has a value even if the type of that value is the void type. An operation is assigned to a block when it is appended via building, so any non-top-level operation in a model must have a result.
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/222#discussion_r1751119610
More information about the babylon-dev
mailing list