From 60374c7f8b6dd24ac9764c3bb1538b457343083b Mon Sep 17 00:00:00 2001 From: sksamuel Date: Thu, 28 Jan 2021 23:18:13 -0600 Subject: [PATCH] Allow registration of custom Show typeclasses #2021 --- .../src/commonMain/kotlin/io/kotest/assertions/show/Show.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kotest-assertions/kotest-assertions-shared/src/commonMain/kotlin/io/kotest/assertions/show/Show.kt b/kotest-assertions/kotest-assertions-shared/src/commonMain/kotlin/io/kotest/assertions/show/Show.kt index b062cd2734e..8bb962efc40 100644 --- a/kotest-assertions/kotest-assertions-shared/src/commonMain/kotlin/io/kotest/assertions/show/Show.kt +++ b/kotest-assertions/kotest-assertions-shared/src/commonMain/kotlin/io/kotest/assertions/show/Show.kt @@ -74,8 +74,8 @@ expect fun platformShow(a: A): Show? @Suppress("UNCHECKED_CAST") fun commonShowFor(t: T): Show { // lookup a show from the registered typeclasses - val show = Shows.all().keys.firstOrNull { it.isInstance(t) } - if (show != null) return show as Show + val kclass = Shows.all().keys.firstOrNull { it.isInstance(t) } + if (kclass != null) Shows.all()[kclass] as Show // this won't work in JS or native, so they'll get the boring old toString version if (io.kotest.mpp.reflection.isDataClass(t::class)) return dataClassShow() return DefaultShow