-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add tasty Show type class and us in Tasty.XYZ.show #4577
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
For XYZ: Tree, TypeOrBoundTree, TypeOrBound and Constant
cd3e0f0
to
b315dbf
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
@@ -2,22 +2,19 @@ package scala.tasty.util | |||
|
|||
import scala.tasty.Tasty | |||
|
|||
class TastyPrinter[T <: Tasty with Singleton](val tasty: T) { | |||
class ShowExtractors[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty0) { |
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 hope the name ShowExtractors
can be improved later if possible.
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.
Yes
Without this change, `showExtractors` is unstable and so is `showExtractors.tasty`, so `showExtractors.showTypeOrBounds`'s type gets approximated from `showExtractors.tasty.TypeOrBounds` to its bounds (`Any` or `Nothing` depending on variance), so the additions to the testcase fail. The same applies to other members. I also tried replacing `tasty.Tree` with `T#Tree` (and so on), but apparently those two types aren't considered equal, at least by Scalac (which is arguably a bug). Relates to code added in scala#4577.
@@ -24,6 +25,15 @@ object TastyImpl extends scala.tasty.Tasty { | |||
def toTasty(implicit ctx: Context): TypeTree = PickledQuotes.quotedTypeToTree(x) | |||
} | |||
|
|||
// ===== Show ===================================================== | |||
|
|||
def defaultShow: Show[this.type] = showExtractors |
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.
Using def
here makes the member unstable problems, see c9dbecc — I'm not using the API you used, but I'd expect both to work as they usually do.
Without this change, `showExtractors` is unstable and so is `showExtractors.tasty`, so `showExtractors.showTypeOrBounds`'s type gets approximated from `showExtractors.tasty.TypeOrBounds` to its bounds (`Any` or `Nothing` depending on variance), so the additions to the testcase fail. The same applies to other members. I also tried replacing `tasty.Tree` with `T#Tree` (and so on), but apparently those two types aren't considered equal, at least by Scalac (which is arguably a bug). Relates to code added in scala#4577.
For XYZ: Tree, TypeOrBoundTree, TypeOrBound and Constant