Permalink
Browse files

SI-8024 Improve user-level toString of package objects

We were outputing a the unattractive `package package`;
now we opt for `package object pack`.

Under `-Ydebug`, we still go to the "accurate" mode of the
old `toString` implementation, which differentiates package objects
vs package object classes.
  • Loading branch information...
1 parent e6cee26 commit b2b9cf4f8c8ff8a00d19aabd56f0602c2aced4b3 @retronym retronym committed Dec 2, 2013
Showing with 9 additions and 5 deletions.
  1. +8 −4 src/reflect/scala/reflect/internal/Symbols.scala
  2. +1 −1 test/files/neg/t8024.check
@@ -2475,10 +2475,14 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** String representation, including symbol's kind e.g., "class Foo", "method Bar".
* If hasMeaninglessName is true, uses the owner's name to disambiguate identity.
*/
- override def toString: String = compose(
- kindString,
- if (hasMeaninglessName) owner.decodedName + idString else nameString
- )
+ override def toString: String = {
+ if (isPackageObjectOrClass && !settings.debug)
+ s"package object ${owner.decodedName}"
+ else compose(
+ kindString,
+ if (hasMeaninglessName) owner.decodedName + idString else nameString
+ )
+ }
/** String representation of location.
*/
@@ -1,5 +1,5 @@
t8024.scala:13: error: reference to sqrt is ambiguous;
-it is both defined in package package and imported subsequently by
+it is both defined in package object p and imported subsequently by
import java.lang.Math.sqrt
sqrt(0d)
^

1 comment on commit b2b9cf4

Job pr-scala failed for b2b9cf4 Took 152 min. (ping @retronym) (results):


To retry exactly this commit, comment "PLS REBUILD/pr-scala@b2b9cf4f8c8ff8a00d19aabd56f0602c2aced4b3" on PR 3214.
NOTE: New commits are rebuilt automatically as they appear. A forced rebuild is only necessary for transient failures.

Please sign in to comment.