File tree 2 files changed +8
-11
lines changed
2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -99,9 +99,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
99
99
val maxPrintElements = ctx.settings.VreplMaxPrintElements .valueIn(ctx.settingsState)
100
100
val maxPrintCharacters = ctx.settings.VreplMaxPrintCharacters .valueIn(ctx.settingsState)
101
101
// stringOf returns null if value.toString returns null. Show some text as a fallback.
102
- def toIdentityString (value : Object ): String =
103
- s " ${value.getClass.getName}@ ${System .identityHashCode(value).toHexString}"
104
- def fallback = s """ ${toIdentityString(value)} // return value of " ${sym.name}.toString" is null """
102
+ def fallback = s """ null // result of " ${sym.name}.toString" is null """
105
103
if value == null then " null" else
106
104
myReplStringOf(value, maxPrintElements, maxPrintCharacters) match
107
105
case null => fallback
Original file line number Diff line number Diff line change @@ -352,18 +352,17 @@ class ReplCompilerTests extends ReplTest:
352
352
run(" val tpolecat = new Object { override def toString(): String = null }" )
353
353
.andThen:
354
354
val last = lines().last
355
- assertTrue(last, last.startsWith(" val tpolecat: Object = anon " ))
356
- assertTrue(last, last.endsWith(""" // return value of "tpolecat.toString" is null""" ))
355
+ assertTrue(last, last.startsWith(" val tpolecat: Object = null " ))
356
+ assertTrue(last, last.endsWith(""" // result of "tpolecat.toString" is null""" ))
357
357
358
358
@ Test def `i17333 print toplevel object with null toString` : Unit =
359
359
initially :
360
360
run(" object tpolecat { override def toString(): String = null }" )
361
- .andThen:
362
- run(" tpolecat" )
363
- val last = lines().last
364
- assertTrue(last, last.startsWith(" val res0: tpolecat.type = tpolecat" ))
365
- assertTrue(last, last.endsWith(""" // return value of "res0.toString" is null""" ))
366
- end ReplCompilerTests
361
+ .andThen:
362
+ run(" tpolecat" )
363
+ val last = lines().last
364
+ assertTrue(last, last.startsWith(" val res0: tpolecat.type = null" ))
365
+ assertTrue(last, last.endsWith(""" // result of "res0.toString" is null""" ))
367
366
368
367
object ReplCompilerTests :
369
368
You can’t perform that action at this time.
0 commit comments