diff --git a/compiler/src/dotty/tools/repl/Rendering.scala b/compiler/src/dotty/tools/repl/Rendering.scala index adefe62d2b5f..d5688d1038b4 100644 --- a/compiler/src/dotty/tools/repl/Rendering.scala +++ b/compiler/src/dotty/tools/repl/Rendering.scala @@ -100,9 +100,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None): val maxPrintElements = ctx.settings.VreplMaxPrintElements.valueIn(ctx.settingsState) val maxPrintCharacters = ctx.settings.VreplMaxPrintCharacters.valueIn(ctx.settingsState) // stringOf returns null if value.toString returns null. Show some text as a fallback. - def toIdentityString(value: Object): String = - s"${value.getClass.getName}@${System.identityHashCode(value).toHexString}" - def fallback = s"""${toIdentityString(value)} // return value of "${sym.name}.toString" is null""" + def fallback = s"""null // result of "${sym.name}.toString" is null""" if value == null then "null" else myReplStringOf(value, maxPrintElements, maxPrintCharacters) match case null => fallback diff --git a/compiler/test/dotty/tools/repl/ReplCompilerTests.scala b/compiler/test/dotty/tools/repl/ReplCompilerTests.scala index a179b5e47f47..a5bdddc51118 100644 --- a/compiler/test/dotty/tools/repl/ReplCompilerTests.scala +++ b/compiler/test/dotty/tools/repl/ReplCompilerTests.scala @@ -436,8 +436,8 @@ class ReplCompilerTests extends ReplTest: run("val tpolecat = new Object { override def toString(): String = null }") .andThen: val last = lines().last - assertTrue(last, last.startsWith("val tpolecat: Object = anon")) - assertTrue(last, last.endsWith("""// return value of "tpolecat.toString" is null""")) + assertTrue(last, last.startsWith("val tpolecat: Object = null")) + assertTrue(last, last.endsWith("""// result of "tpolecat.toString" is null""")) @Test def `i17333 print toplevel object with null toString`: Unit = initially: @@ -445,8 +445,8 @@ class ReplCompilerTests extends ReplTest: .andThen: run("tpolecat") val last = lines().last - assertTrue(last, last.startsWith("val res0: tpolecat.type = tpolecat")) - assertTrue(last, last.endsWith("""// return value of "res0.toString" is null""")) + assertTrue(last, last.startsWith("val res0: tpolecat.type = null")) + assertTrue(last, last.endsWith("""// result of "res0.toString" is null""")) object ReplCompilerTests: