Skip to content

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

Merged

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@nicolasstucki nicolasstucki self-assigned this Sep 24, 2020
@nicolasstucki nicolasstucki force-pushed the refactor-Reflect-implicit-search branch from 9546cc5 to 8eff3e9 Compare September 24, 2020 14:14
@nicolasstucki nicolasstucki force-pushed the refactor-Reflect-implicit-search branch 2 times, most recently from fcf96de to 663134e Compare September 29, 2020 12:21
@nicolasstucki nicolasstucki marked this pull request as ready for review September 29, 2020 15:03
Copy link
Contributor

@liufengyun liufengyun 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

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`.
Copy link
Contributor

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.

Copy link
Contributor

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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

@nicolasstucki nicolasstucki force-pushed the refactor-Reflect-implicit-search branch from 663134e to 83e93a8 Compare October 5, 2020 14:46
Copy link
Contributor

@liufengyun liufengyun 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


type ImplicitSearchResult <: AnyRef
/** Result of a given instance search */
type ImplicitSearch <: AnyRef
Copy link
Contributor

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.

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 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`.
Copy link
Contributor

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)?

@nicolasstucki nicolasstucki force-pushed the refactor-Reflect-implicit-search branch from 83e93a8 to 918ae10 Compare October 6, 2020 06:31
Move implicit search method into implicit search module. This makes the Relfect API more design more homogeneous.
@nicolasstucki nicolasstucki force-pushed the refactor-Reflect-implicit-search branch from 918ae10 to 2fdc20b Compare October 6, 2020 06:33
@nicolasstucki nicolasstucki merged commit a164668 into scala:master Oct 6, 2020
@nicolasstucki nicolasstucki deleted the refactor-Reflect-implicit-search branch October 6, 2020 11:37
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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.

4 participants