- Notifications
You must be signed in to change notification settings - Fork 1.1k
Print wildcard star properly (fix #14495) #14496
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
a666eae to 6dc9c0b 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.
Looks good to me but @odersky or @nicolasstucki should review as well
2b59e53 to 7b283fc Compare 7b283fc to d5cd781 Compare | // avoid the double `*` in this case. | ||
| toText(expr) | ||
| case _ => | ||
| toText(expr) ~ "*" |
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.
* instead of _: * is valid syntax in Scala 3.
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, it should be "*", not ": *"
| keywordStr("throw ") ~ toText(expr) | ||
| } | ||
| case SeqLiteral(elems, elemtpt) => | ||
| "[" ~ toTextGlobal(elems, ",") ~ " : " ~ toText(elemtpt) ~ "]" |
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.
A SeqLiteral is a specific kind of tree node, when debugging the compiler output with -Xprint, it's useful to be able to distinguish a SeqLiteral produced by the compiler from a Seq tree written by the user. If this doesn't appear in something that the compiler prints to the user then I don't think it should be changed.
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.
Agree with @smarter. We should at least retain the old output under -Yprint-debug
| It appears in compiletime.codeOf Guillaume Martres ***@***.***>于2022年2月19日 周六上午8:51写道: … ***@***.**** commented on this pull request. ------------------------------ In compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala <#14496 (comment)>: > @@ -513,7 +513,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { keywordStr("throw ") ~ toText(expr) } case SeqLiteral(elems, elemtpt) => - "[" ~ toTextGlobal(elems, ",") ~ " : " ~ toText(elemtpt) ~ "]" A SeqLiteral is a specific kind of tree node, when debugging the compiler output with -Xprint, it's useful to be able to distinguish a SeqLiteral produced by the compiler from a Seq tree written by the user. If this doesn't appear in something that the compiler prints to the user then I don't think it should be changed. — Reply to this email directly, view it on GitHub <#14496 (review)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAES3OTQGG3XJ6NTJRDC3DLU37DBFANCNFSM5OQ4CYBA> . Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>. You are receiving this because you authored the thread.Message ID: ***@***.***> |
| OK, I don't know what the intended purpose of codeOf is, but if it's supposed to produce code that compiles, it shouldn't rely on RefinedPrinter only. |
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.
Overall, I don't see that this improves things. I believe it would be good to make an effort to get to a printer that only outputs code that can be parsed back.
But there is a natural tension between that and diagnostics that give more information. So rather than fiddling with details I believe we need an overall strategy how we can get to such a printer without duplicating a huge amount of code.
| // avoid the double `*` in this case. | ||
| toText(expr) | ||
| case _ => | ||
| toText(expr) ~ "*" |
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, it should be "*", not ": *"
| keywordStr("throw ") ~ toText(expr) | ||
| } | ||
| case SeqLiteral(elems, elemtpt) => | ||
| "[" ~ toTextGlobal(elems, ",") ~ " : " ~ toText(elemtpt) ~ "]" |
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.
Agree with @smarter. We should at least retain the old output under -Yprint-debug
| We do have showDecompiledTree ( https://github.com/lampepfl/dotty/blob/cf9525c713b99ae4046234f8ff350c97a9d380d0/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala#L29 ), I don't know if it could be reused for codeOf /cc @nicolasstucki |
|
|
| Hey @Atry do you plan on returning back to this? |
No description provided.