-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use extension methods in TASTy Reflect #7399
Conversation
7d8670b
to
c591f2b
Compare
535a7e3
to
0cb392f
Compare
* Remove redundant extension methods * Use given extension methods
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.
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) | ||
|
||
} |
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.
Use extension methods here (and below), instead of implicit class?
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.
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 | |||
|
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.
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 { |
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.
Why they have to create Printers
, when they really want is just a Printer
?
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.
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 = { |
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.
The type signature does not look nice.
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 agree. Would be improved if I manage to decouple the contents of Printers
@milessabin in this PR I modified a couple of TASTy reflect imports in shapeless. |
@nicolasstucki thanks for the heads up! |
No description provided.