Skip to content

Fix two problems related to match types as array elements#15625

Merged
odersky merged 3 commits into
scala:mainfrom
dotty-staging:fix-15618
Jul 10, 2022
Merged

Fix two problems related to match types as array elements#15625
odersky merged 3 commits into
scala:mainfrom
dotty-staging:fix-15618

Conversation

@odersky

@odersky odersky commented Jul 8, 2022

Copy link
Copy Markdown
Contributor
  1. The erasure of an array of matchtypes should sometimes be Object
    instead of Object[]
  2. Classtags of matchtypes can be created only if all alternatives
    produce the same classtag.

About 1: If a matchtype with alternative types A_1, ... A_n is an array element,
it should be treated in the same way as the type ? <: A_1 | ... | A_n. It's an
unknown subtype of A_1 | ... | A_n. That can cause the erasure of the underlying
array to be Object.

Fixes #15618

 1. The erasure of an array of matchtypes should sometimes be Object
    instead of Object[]
 2. Classtags of matchtypes can be created only if all alternatives
    produce the same classtag.

About 1: If a matchtype with alternative types A_1, ... A_n is an array element,
it should be treated in the same way as the type ? <: A_1 | ... | A_n. It's an
_unknown_ subtype of A_1 | ... | A_n. That can cause the erasure of the underlying
array to be Object.

Fixes scala#15618
@odersky odersky requested a review from smarter July 8, 2022 19:00
@odersky odersky assigned odersky and smarter and unassigned odersky Jul 8, 2022
@odersky odersky merged commit 11d65aa into scala:main Jul 10, 2022
@odersky odersky deleted the fix-15618 branch July 10, 2022 08:04
@smarter smarter added the backport:accepted This PR needs to be backported, once it's been backported replace this tag by "backport:done" label Jul 10, 2022
@smarter

smarter commented Jul 14, 2022

Copy link
Copy Markdown
Member

@Kordyjan Should we open an issue that tracks PRs that should be backported for the next release? In theory the backport:accepted is here for that purpose, but it's easy to miss that since it applies to closed PRs.

@Kordyjan

Copy link
Copy Markdown
Contributor

@smarter I was on vacation last two weeks. That is why there was no activity around the backports.

I'm regularly checking for the PRs marked with backport:* labels, so right now, creating a new issue every time we need a backport, wouldn't be that helpful.

@smarter

smarter commented Jul 26, 2022

Copy link
Copy Markdown
Member

Ok sounds good!

Kordyjan added a commit that referenced this pull request Jul 27, 2022
Backport #15625: Fix two problems related to match types as array elements
@Kordyjan Kordyjan added backport:done This PR was successfully backported. and removed backport:accepted This PR needs to be backported, once it's been backported replace this tag by "backport:done" labels Jul 27, 2022
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:done This PR was successfully backported.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Array parameterized with match type causes ClassCastException at runtime

4 participants