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 8bb962efc40..b044eabd46a 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,11 @@ expect fun platformShow(a: A): Show? @Suppress("UNCHECKED_CAST") fun commonShowFor(t: T): Show { // lookup a show from the registered typeclasses - val kclass = Shows.all().keys.firstOrNull { it.isInstance(t) } - if (kclass != null) Shows.all()[kclass] as Show + val kclass: KClass<*>? = Shows.all().keys.firstOrNull { it.isInstance(t) } + if (kclass != null) { + val show: Show<*>? = Shows.all()[kclass] + return show 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