-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Omit more prefixes in non-package module printing #17758
Omit more prefixes in non-package module printing #17758
Conversation
When we pretty-print a type in a module class, we end up printing the module class's symbol. For instance in a reduction failure of Tuple.Union, we end up printing Tuple.Fold, with Tuple being an internal (ThisType) reference to the Tuple module class. I tweaked the logic in fullNameString so that we omit more prefixes, if the module is non-package (and make it consistent across -Ytest-pickler). The package part is important, because we want to continue to get "import scala.concurrent.duration..." instead of "import concurrent.duration..".
1cc5c18
to
77ee20b
Compare
If you refer to a package by name, e.g. `scala.quoted.Quotes`, the type may have a "quoted" prefix that is a TermRef. Rather than unravel the rest of the prefixes, we print the fully package name.
77ee20b
to
c04bb4f
Compare
@@ -106,6 +109,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { | |||
if (tp.cls.isAnonymousClass) keywordStr("this") | |||
if (tp.cls.is(ModuleClass)) fullNameString(tp.cls.sourceModule) | |||
else super.toTextRef(tp) | |||
case tp: TermRef if !printDebug => | |||
if tp.symbol.is(Package) then fullNameString(tp.symbol) |
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 caused a bit of regression in metals since we are no longer able to omit a package when printing : scalameta/metals#5327
I wonder if you could do a bit more full proof mechanism here so that we always correctly skip prefixes in both metals and compiler 🤔 It's influenced by the imports within metals.
When we pretty-print a type in a module class, we end up printing the
module class's symbol. For instance in a reduction failure of
Tuple.Union, we end up printing Tuple.Fold, with Tuple being an internal
(ThisType) reference to the Tuple module class. I tweaked the logic in
fullNameString so that we omit more prefixes, if the module is
non-package (and make it consistent across -Ytest-pickler). The package
part is important, because we want to continue to get "import
scala.concurrent.duration..." instead of "import concurrent.duration..".