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

Add a check for correct Array shape in quotes.reflect.ClassOfConstant #22033

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jchyb
Copy link
Contributor

@jchyb jchyb commented Nov 26, 2024

Closes #21916
I tried to supply the ClassOfConstant with multiple other broken Types, but I was unable to break it beyond the linked issue, so I ended up adding the check for only that one case. This makes sense - the backend (and thus erasure) needs to know if the Array type parameter is a primitive type, but in other cases the erasure phase needs to know only the class, without the type parameters.

It's impossible to call classOf through the quoted code ('{classOf[t]} with a boundless t will error out), so we don't need that additional check there.

There does appear to be an issue with being able to set '{List[Array]} resulting in a crash, but that is beyond the scope of this fix - I will prepare a separate issue for that (edit: reported here).

Comment on lines 2526 to 2528
typeRepr match
case AppliedType(_, Nil) => isArray
case _ => isArray
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a pattern matching if both branches have a similar result ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot about case AppliedType(_, _) where we would not check isArray. I've adjusted this to be clearer anyway.

@jchyb jchyb force-pushed the fix-i21916-array-check branch from 164a8ed to 80ae408 Compare January 9, 2025 11:15
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.

assertion failed: class Array while introspecting Array[Byte] in a macro
2 participants