Skip to content

Use extension methods in TASTy Reflect #7399

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

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@nicolasstucki nicolasstucki changed the title Use extension methods in tasty reflect Use extension methods in TASTy Reflect Oct 9, 2019
@nicolasstucki nicolasstucki force-pushed the use-extension-methods-in-tasty-reflect branch 4 times, most recently from 7d8670b to c591f2b Compare October 9, 2019 16:00
@nicolasstucki nicolasstucki force-pushed the use-extension-methods-in-tasty-reflect branch from 535a7e3 to 0cb392f Compare October 9, 2019 17:33
* Remove redundant extension methods
* Use given extension methods
@nicolasstucki nicolasstucki self-assigned this Oct 9, 2019
@nicolasstucki nicolasstucki marked this pull request as ready for review October 9, 2019 20:55
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.

LGTM

Not caused by this PR, I find the following import syntax not friendly to programmers:

import qctx.tasty.{_, given}

val printers = new Printers(self)
new printers.SourceCodePrinter(syntaxHighlight).showTree(tree)

}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use extension methods here (and below), instead of implicit class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are blocked by #7401

@@ -157,8 +157,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
if (self.symbol.is(core.Flags.JavaDefined)) Nil // FIXME should also support java packages
else self.symbol.info.decls.iterator.map(definitionFromSym).toList

def PackageDef_symbol(self: PackageDef)(given Context): Symbol = self.symbol

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice simplification of the contract 👍

def dummyShow(given qctx: QuoteContext): scala.tasty.reflect.Printers[qctx.tasty.type]#Printer = {
import qctx.tasty.{_, given}
val printers = new scala.tasty.reflect.Printers(qctx.tasty)
new printers.Printer {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why they have to create Printers, when they really want is just a Printer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that I have this decoupled I may be able to completely decouple the different Printer implementations and use them directly. I will do that in another PR as it is just taking this refactoring one step further.

def dummyShow(given qctx: QuoteContext): qctx.tasty.Printer = {
import qctx.tasty._
new Printer {
def dummyShow(given qctx: QuoteContext): scala.tasty.reflect.Printers[qctx.tasty.type]#Printer = {
Copy link
Contributor

Choose a reason for hiding this comment

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

The type signature does not look nice.

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 agree. Would be improved if I manage to decouple the contents of Printers

@nicolasstucki nicolasstucki merged commit d9a5409 into scala:master Oct 10, 2019
@nicolasstucki nicolasstucki deleted the use-extension-methods-in-tasty-reflect branch October 10, 2019 08:04
@nicolasstucki
Copy link
Contributor Author

@milessabin in this PR I modified a couple of TASTy reflect imports in shapeless.

@milessabin
Copy link
Contributor

@nicolasstucki thanks for the heads up!

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.

3 participants