-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make REPL type echo-ing use partially qualified names where made possible by imports #24850
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
base: main
Are you sure you want to change the base?
Conversation
| val xs: List[Int] = List(1) | ||
| scala> scala.util.Try(1) | ||
| val res0: scala.util.Try[Int] = Success(1) | ||
| val res0: util.Try[Int] = Success(1) |
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 we maybe show the full path when no import was added? This comes from the defaults, but might be confusing, since we also have java.util
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.
But Java.util and any other util package is likely not imported
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 write code like util.Success and collection.Seq pretty frequently, taking advantage of the default imports. These shorthands are based on what symbols actually match, so there shouldn't be any ambiguity in meaning. If someone does import java.util or something it will fall back to the fully qualified name since the imported java.util will not be the same as scala.util
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.
It's likely my personal preference then 😅 Maybe not important
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 often wonder if util is dotc.util. Naming is so hard. If only superscripts could help here? Color-coding? Red for scala, blue for java, green for dotty.
tgodzik
left a comment
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, looks like a nice improvement. LGTM! Anyone has any other comments?
collection.mutable.Buffer()echoingb: scala.collection.mutable.Buffer[T], it echoescollection.mutable.Bufferby default sincescala.collectionis imported bydefaultimport scala.collection.mutable, it then echoesb: mutable.Buffer[T]import scala.collection.mutable.Buffer, it echoesb: Buffer[T]This feature was in Ammonite/PPrint, and while the implementation in the Scala compiler is totally different, in the end it does basically the same thing: when stringifying the type, it looks for things in scope that match the current type prefix, and if finds something then it prints the name of the name in scope rather than the full prefix
Added a unit test file to cover this, and updated all the existing tests that needed updating