diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 85bc3158f694..5705f8484abd 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -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. */ diff --git a/test/files/neg/t8024.check b/test/files/neg/t8024.check index f04e4add9ccf..bd551aa59173 100644 --- a/test/files/neg/t8024.check +++ b/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) ^