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

Introduce MethodTypeKind to quotes reflection API #20249

Merged
merged 2 commits into from
Apr 25, 2024

Conversation

jchyb
Copy link
Contributor

@jchyb jchyb commented Apr 23, 2024

It allows to create Contextual and Implicit MethodTypes. MethodTypeKind abstracts away the MethodTypeCompanion implementation into a simple enum style choice for a newly added MethodType apply method. The MethodType unapply is kept as it was for source compatibility, instead users are encouraged to use isImplicit and isContextual methods.

Based on #18499
Fixes #18477

@jchyb jchyb marked this pull request as ready for review April 23, 2024 13:56
@jchyb jchyb added the needs-minor-release This PR cannot be merged until the next minor release label Apr 23, 2024
Copy link
Contributor

@nicolasstucki nicolasstucki left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala Outdated Show resolved Hide resolved
It allows to create Contextual and Implicit MethodTypes.
MethodTypeKind abstracts away the MethodTypeCompanion
implementation into a simple enum style choice for a newly added
MethodType apply. The MethodType unapply is kept as it was for source
compatibility, instead users are encouraged to use isImplicit and
isContextual methods.
@@ -3234,6 +3236,22 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
/** `TypeTest` that allows testing at runtime in a pattern match if a `TypeRepr` is a `MethodOrPoly` */
given MethodOrPolyTypeTest: TypeTest[TypeRepr, MethodOrPoly]

/** Type which decides on the kind of parameter list represented by `MethodType`. */
type MethodTypeKind
Copy link
Member

Choose a reason for hiding this comment

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

Have you considered making this a concrete, static enum instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, it could work.

@Gedochao
Copy link
Contributor

This has been decided to be included in the 3.5.0 release.

@jchyb
Copy link
Contributor Author

jchyb commented Apr 25, 2024

I have changed the implementation to use enums. I guess this is better - users get nicer pattern matching and the MethodTypeCompanion is also better hidden (printlns on MethodTypeKind will be less confusing)

@nicolasstucki nicolasstucki merged commit 00802ab into scala:main Apr 25, 2024
17 checks passed
@nicolasstucki nicolasstucki deleted the fix-i18477 branch April 25, 2024 11:36
@Kordyjan Kordyjan added this to the 3.5.0 milestone May 10, 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.

Add contextual method types to Quotes API
5 participants