-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
This has been decided to be included in the 3.5.0 release. |
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) |
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 useisImplicit
andisContextual
methods.Based on #18499
Fixes #18477