Incorrect binary numeric promotion in conditional expression

Issue #157 resolved
Jesper Öqvist created an issue

ExtendJ 8.0.1-98-ge82120a

There is an error in conditional expression type analysis causing an incorrect type to be computed when one operand has type byte and the other has type Byte. The test type/conditional_expr_02p in the regression test suite exposes this error:

class Test {
  byte test(byte a, Byte b, boolean c) {
    return c ? a : b;

ExtendJ reports the following error for the above code:

    [junit] tests/type/conditional_expr_02p/ error: return value must be an instance of byte which int is not

The error is caused by using a binary numeric promotion too early. Binary numeric promotion should not occur when one operand is just the boxed type of the other operand type.

Comments (1)

  1. Log in to comment