Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Array.appendAll() arraycopy type mismatch #2794

Merged
merged 1 commit into from
Aug 17, 2024
Merged

Conversation

pivovarit
Copy link
Member

@pivovarit pivovarit commented Aug 17, 2024

Internal Array.appendAll optimizations sometimes would result in returning arrays of the wrong type.

private interface SomeInterface {
}

enum OneEnum implements SomeInterface {
    A1, A2, A3;
}

enum SecondEnum implements SomeInterface {
    A1, A2, A3;
}

public static void main(String[] args) {
    Array<SomeInterface> empty = Array.empty();
    Array<SomeInterface> copy1 = empty.appendAll(Array.<SomeInterface>of(OneEnum.values()));
    Array<SomeInterface> copy2 = copy1.appendAll(Array.<SomeInterface>of(SecondEnum.values()));
}

fixes: #2781

@pivovarit pivovarit marked this pull request as ready for review August 17, 2024 15:39
@pivovarit pivovarit merged commit d32fdfa into master Aug 17, 2024
4 checks passed
@pivovarit pivovarit deleted the append-all-enum branch August 17, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Array.appendAll throws exception, when trying to work with Enums
1 participant