Hi, I am trying to simplify Guice binding using re...
# announcements
d
Hi, I am trying to simplify Guice binding using reified generics, but it doesn't work. Here is a bit of the code that I am trying to simplify
Copy code
bind(object : TypeLiteral<KafkaConsumer<String, QuoteServed>>() {}).toProvider(object : TypeLiteral<KafkaConsumerFactory<QuoteServed>>() {})
        bind(object : TypeLiteral<EventConsumer<QuoteServed>>() {}).to(object : TypeLiteral<KafkaEventConsumer<QuoteServed>>() {})
to this:
Copy code
bindSpecial<QuoteServed>()

    private inline fun <reified T: SpecificRecord> bindSpecial(){
        bind(object : TypeLiteral<KafkaConsumer<String, T>>() {}).toProvider(object : TypeLiteral<KafkaConsumerFactory<T>>() {})
        bind(object : TypeLiteral<EventConsumer<T>>() {}).to(object : TypeLiteral<KafkaEventConsumer<T>>() {})
    }
but it fails with
org.apache.kafka.clients.consumer.KafkaConsumer<java.lang.String, T> cannot be used as a key; It is not fully specified.
. I probably misunderstand how the inlining works, but I thought the inlined function will be just copied with Generics substituted with actual type