Skip to content

Commit

Permalink
Make error message for captured generic type parameters much more str…
Browse files Browse the repository at this point in the history
…aightforward (#1863)

Fixes #1860
  • Loading branch information
qwwdfsad committed Feb 17, 2022
1 parent c78e950 commit 83003e0
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -99,6 +99,11 @@ internal expect fun KClass<*>.platformSpecificSerializerNotRegistered(): Nothing
@Suppress("UNCHECKED_CAST")
internal fun KType.kclass() = when (val t = classifier) {
is KClass<*> -> t
is KTypeParameter -> {
error("Captured type paramerer $t from generic non-reified function. " +
"Such functionality cannot be supported as $t is erased, either specify serializer explicitly or make " +
"calling function inline with reified $t")
}
else -> error("Only KClass supported as classifier, got $t")
} as KClass<Any>

Expand Down

0 comments on commit 83003e0

Please sign in to comment.