Skip to content

Commit

Permalink
SI-8024 Improve user-level toString of package objects
Browse files Browse the repository at this point in the history
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
retronym committed Dec 12, 2013
1 parent e6cee26 commit b2b9cf4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/reflect/scala/reflect/internal/Symbols.scala
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/t8024.check
@@ -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)
^
Expand Down

1 comment on commit b2b9cf4

@scala-jenkins
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.