Polymorphic SerializersModule with generic class "Star projections in type arguments are not allowed"
See original GitHub issueConsider this code:
val responseModule = SerializersModule {
polymorphic(Response::class) {
subclass(OkResponse::class)
}
}
@Serializable
abstract class Response<out T>
@Serializable
class OkResponse<out T>(val data: T) : Response<T>()
Running it produces:
Caused by: java.lang.IllegalArgumentException: Star projections in type arguments are not allowed, but had example.examplePoly17.OkResponse<*> (Kotlin reflection is not available)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:25
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Polymorphic SerializersModule with generic class "Star projections ...
Polymorphic SerializersModule with generic class "Star projections in type arguments are not allowed"
Read more >kotlin - error: Star projections in type arguments are not allowed
I want to deserialize JSON into a data class, Message , that has a field with a generic type. import kotlinx.serialization.SerialName import ...
Read more >Generics and Polymorphism - Whizlabs Blog
The polymorphism applies only to the 'base' type (type of the collection class) and NOT to the generics type. Generic Methods. To understand...
Read more >[client/server] Support polymorphic serializers : KTOR-1514
The following does not work because the type is generic and polymorphic. ... Star projections in type arguments are not allowed, ...
Read more >Serializable - Kotlin
The main entry point to the serialization process. · For classes with generic type parameters, · In order to generate serializer function that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not sure this is related, but I had the same error.
I found the following workaround: in my case, there was an interface constraint on the generic, and I could register the
subclass
as follows causing the error to disappear:Nope