-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fixes #3683 REPL: Incorrect pretty-printing of singleton types #4132
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
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.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Commit Messages
We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).
Please stick to these guidelines for commit messages:
- Separate subject from body with a blank line
- When fixing an issue, start your commit message with
Fix #<ISSUE-NBR>:
- Limit the subject line to 72 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line ("Add" instead of "Added")
- Wrap the body at 80 characters
- Use the body to explain what and why vs. how
adapted from https://chris.beams.io/posts/git-commit
Have an awesome day! ☀️
I will fix the tests if this fix is ok. |
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 think one must keep the current output in examples like
scala> final val a = "foo"
val a: String("foo") = "foo"
If there aren't tests enforcing this behavior, this is a good time to add them, but I hope those are the failing tests.
@allanrenucci I am not able to differentiate between |
TL;DR
but for other singleton types (
(Also wondering what happens on the other subclasses of Details@allanrenucci convinced me to reconsider. We can replace
Sorry for being unclear, you don't need to find whether |
Adding In the test "methodDoesNotTakeMorePrameters" - |
@eklavya Can you push your current solution to see all the test cases that break |
@allanrenucci pushed, I am messing around with the types of SingletonType to figure out a way to make it work without changing existing behaviour on defs, which I can't seem to find. |
@eklavya I pushed a commit that fixes the error message test failures. For the other test failures you should update the tests |
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 believe the changes should go into RefinedPrinter
instead
@@ -141,6 +141,10 @@ class PlainPrinter(_ctx: Context) extends Printer { | |||
ParamRefNameString(tp) ~ ".type" | |||
case tp: TypeParamRef => | |||
ParamRefNameString(tp) ~ lambdaHash(tp.binder) | |||
case tp: ConstantType => |
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.
Should be:
case ConstantType(value) =>
toText(value)
case tp: ConstantType => | ||
toTextRef(tp) | ||
case tp: TermRef => | ||
toTextPrefix(tp.prefix) ~ selectionString(tp) ~ ".type" |
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 special case TermRef
?
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.
This is for a.type
singleton types.
scala> final val a = "foo"
val a: "foo" = foo
scala> val x: a.type = a
val x: a.type = foo
a.type is made by special casing TermRef. I am sorry if that's nonsensical 😛
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.
That makes some sense, but there are other cases above for tp: TermRef
which already produce toTextRef(tp) ~ ".type"
(which is equivalent to the code here), do they not apply?
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 had missed that. No, those cases (in PlainPrinter) are not applied because of the guards.
@eklavya The PR is getting really old... If you plan to work again on it please reopen or make a new one, I will close it for now. |
No description provided.