-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Refactor Reflect implicit search #9863
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
Refactor Reflect implicit search #9863
Conversation
9546cc5
to
8eff3e9
Compare
fcf96de
to
663134e
Compare
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
protected val ImplicitSearchSuccessTypeTest: TypeTest[ImplicitSearchResult, ImplicitSearchSuccess] | ||
trait ImplicitSearchModule { self: ImplicitSearch.type => | ||
/** Find a given instance of type `T` in the current scope. | ||
* Return an `ImplicitSearch`. |
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.
Will it find Scala2 implicit
instances? The "current scope' needs some explanation.
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.
Maybe change the current scope
to the current scope (e.g., the call site of a macro)
?
@@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl } | |||
|
|||
private def fImpl (using qctx: QuoteContext) : Expr[Unit] = { | |||
import qctx.tasty._ | |||
searchImplicit(('[A]).unseal.tpe) match { | |||
ImplicitSearch(('[A]).unseal.tpe) match { |
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.
Minor: usually the convention for .apply
methods is to simply construct an object from arguments. It seems here Implicits.search
might be more idiomatic.
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.
Indeed. I will try it out
663134e
to
83e93a8
Compare
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
|
||
type ImplicitSearchResult <: AnyRef | ||
/** Result of a given instance search */ | ||
type ImplicitSearch <: AnyRef |
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.
I find the previous name is better for readability. Meanwhile, maybe use "implicit instance search" in the docs for consistency and precision: as Scala2 implicits are not given instances.
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.
I will go back to ImplicitSearchResult now that we don't have to use it in source
protected val ImplicitSearchSuccessTypeTest: TypeTest[ImplicitSearchResult, ImplicitSearchSuccess] | ||
trait ImplicitSearchModule { self: ImplicitSearch.type => | ||
/** Find a given instance of type `T` in the current scope. | ||
* Return an `ImplicitSearch`. |
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.
Maybe change the current scope
to the current scope (e.g., the call site of a macro)
?
83e93a8
to
918ae10
Compare
Move implicit search method into implicit search module. This makes the Relfect API more design more homogeneous.
918ae10
to
2fdc20b
Compare
No description provided.