Collection.toString() should not throw if it contains itself
Merge-request: KT-MR-10591 Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
6fc02c3408
commit
f152fa537d
@@ -137,18 +137,3 @@ internal external fun arrayCopy(array: DoubleArray, fromIndex: Int, destination:
|
||||
@GCUnsafeCall("Kotlin_BooleanArray_copyImpl")
|
||||
internal external fun arrayCopy(array: BooleanArray, fromIndex: Int, destination: BooleanArray, toIndex: Int, count: Int)
|
||||
|
||||
|
||||
internal fun <E> Collection<E>.collectionToString(): String {
|
||||
val sb = StringBuilder(2 + size * 3)
|
||||
sb.append("[")
|
||||
var i = 0
|
||||
val it = iterator()
|
||||
while (it.hasNext()) {
|
||||
if (i > 0) sb.append(", ")
|
||||
val next = it.next()
|
||||
if (next == this) sb.append("(this Collection)") else sb.append(next)
|
||||
i++
|
||||
}
|
||||
sb.append("]")
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user