Skip to content

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

Merged
merged 1 commit into from
May 25, 2018

Conversation

nicolasstucki
Copy link
Contributor

For XYZ: Tree, TypeOrBoundTree, TypeOrBound and Constant

For XYZ: Tree, TypeOrBoundTree, TypeOrBound and Constant
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

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@nicolasstucki nicolasstucki merged commit a15cfad into scala:master May 25, 2018
@liufengyun liufengyun deleted the add-tasty-show branch May 25, 2018 13:55
Blaisorblade added a commit to dotty-staging/dotty that referenced this pull request May 25, 2018
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
Copy link
Contributor

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.

Blaisorblade added a commit to dotty-staging/dotty that referenced this pull request May 26, 2018
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.
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