Skip to content

Commit 83003e0

Browse files
authored
Make error message for captured generic type parameters much more straightforward (#1863)
Fixes #1860
1 parent c78e950 commit 83003e0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

core/commonMain/src/kotlinx/serialization/internal/Platform.common.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ internal expect fun KClass<*>.platformSpecificSerializerNotRegistered(): Nothing
9999
@Suppress("UNCHECKED_CAST")
100100
internal fun KType.kclass() = when (val t = classifier) {
101101
is KClass<*> -> t
102+
is KTypeParameter -> {
103+
error("Captured type paramerer $t from generic non-reified function. " +
104+
"Such functionality cannot be supported as $t is erased, either specify serializer explicitly or make " +
105+
"calling function inline with reified $t")
106+
}
102107
else -> error("Only KClass supported as classifier, got $t")
103108
} as KClass<Any>
104109

0 commit comments

Comments
 (0)