Skip to content

Add Printer to reflect Constant.show #10755

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

We can either print the structure with the pattern or the code like representation of the value.

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


lazy val ConstantStructure: Printer[Constant] = new Printer[Constant]:
def show(const: Constant): String =
Extractors.showConstant(using QuotesImpl.this)(const)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there usage for ConstantStructure? If ConstantCode is the only printer, maybe change toString and/or show method is enough for practical usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ConstantStructure is mainly used for debugging.

We do not have access to the Context in the to toString which we need to handle the ClassOf case. In general, we tell users that the toString is unreliable and that they should use show, this should not be an exception or it may lead to confusion.

@nicolasstucki nicolasstucki force-pushed the add-printer-to-constant-show branch from 5ab7689 to 71ae463 Compare December 11, 2020 13:58
We can either print the structure with the pattern or the code like representation of the value.
@nicolasstucki nicolasstucki force-pushed the add-printer-to-constant-show branch from 71ae463 to 6f4b958 Compare December 11, 2020 14:09
@nicolasstucki nicolasstucki merged commit afc6396 into scala:master Dec 11, 2020
@nicolasstucki nicolasstucki deleted the add-printer-to-constant-show branch December 11, 2020 16:05
@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.

3 participants