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

Bound TypeRepr by Matchable in Quotes #21377

Merged
merged 1 commit into from
Aug 19, 2024
Merged

Conversation

hamzaremmal
Copy link
Member

Closes #21282

@hamzaremmal hamzaremmal added the needs-minor-release This PR cannot be merged until the next minor release label Aug 13, 2024
@hamzaremmal hamzaremmal requested review from sjrd and jchyb August 13, 2024 10:01
@hamzaremmal hamzaremmal enabled auto-merge August 13, 2024 10:18
@sjrd
Copy link
Member

sjrd commented Aug 13, 2024

Is that not intended? Can we safely match on TypeReprs?

@hamzaremmal
Copy link
Member Author

hamzaremmal commented Aug 13, 2024

Is that not intended? Can we safely match on TypeReprs?

Yes, we can safely match over TypeRepr (under the assumption that only the compiler implements Quotes). We also provide instances of TypeTest, for example:

given ConstantTypeTypeTest: TypeTest[TypeRepr, ConstantType]

Copy link
Contributor

@jchyb jchyb left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!
We might need to go through some other types in Quotes.scala like ImplicitSearchResult, Tree, even some TypeRepr subtypes like AndOrType and also add Matchable there. I'll try to prepare an issue for that and fix it later today.

@hamzaremmal hamzaremmal merged commit b64afad into scala:main Aug 19, 2024
28 checks passed
@hamzaremmal hamzaremmal deleted the i21282 branch August 19, 2024 09:05
@hamzaremmal
Copy link
Member Author

hamzaremmal commented Aug 19, 2024

LGTM. Thank you! We might need to go through some other types in Quotes.scala like ImplicitSearchResult, Tree, even some TypeRepr subtypes like AndOrType and also add Matchable there. I'll try to prepare an issue for that and fix it later today.

I agree, I'm sure there are some other types we need to bind but I didn't want to include these changes here as it closes a specific issue. We don't need to do anything more for subtypes of TypeRepr, the will all be bound by Matchable since now TypeRepr is bound by Matchable:

type AndOrType <: TypeRepr

For Tree and ImplicitSearchResult, the types are already bound by AnyRef and therefore Matchable:

type Tree <: AnyRef

type ImplicitSearchResult <: AnyRef

Nevertheless, a check is welcome.

@jchyb
Copy link
Contributor

jchyb commented Aug 19, 2024

Ah, good point!

@WojciechMazur WojciechMazur added this to the 3.6.0 milestone Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-minor-release This PR cannot be merged until the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

-source:future-migration generating warnings on TypeRepr matches
4 participants