Skip to content

Java: union of arrays produces a compilation failure #5087

Description

@rix0rrr

Describe the bug

The following:

export type X = A[] | B[] | C;

Fails to compile in Java, because type erasure turns this into 2 arrays.

The following does work:

export type X = (A | B)[] | C;

jsii-compiler should reject the former.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

If it passes the compiler it shouldn't fail packaging.

Current Behavior

The opposite.

Reproduction Steps

SEe description.

Possible Solution

No response

Additional Information/Context

No response

SDK version used

Environment details (OS name and version, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.effort/smallSmall work item – less than a day of effortneeds-triageThis issue or PR still needs to be triaged.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions