I hope you don't mind if I jump in...

It's probably worth doing some experiments to get the bounds just right. Here 
are the basic properties we need:

Let's say we have a simple class hierarchy:
```
interface Animal
interface Cat extends Animal
interface Dog extends Animal
```
And let's say we subclass `KeyValue`: `public class KV extends KeyValue`.

Given a `KStream<String, Cat>`, we want to be able to call `flatTransform` with 
a `TransformerSupplier<String, Animal, List<KeyValue<Animal>>>` like this one:
`(String s, Animal a) -> asList(new KV(s, new Cat()), new KeyValue(s, new 
Dog()))`.

The `? super K` and `? super V` ensure that any transformer that _can handle_ a 
`K` and `V` is permitted. You _can handle_ an instance if you can assign it to 
you parameter types (so your parameter type is a supertype of the instance 
type). You need to specify this as a bound because the compiler doesn't 
generally let me assign a supertype to a subtype (I can't write `Cat c = 
(Animal) a;`).

I don't think you actually need the `? extends Whatever` parts to get the right 
outcome. If anything, you might need it on the stuff inside the iterable to 
make sure that you can just pass in heterogeneous members, and they'll get 
"rounded" to their lowest common superclass.

I think this works without `extends` because you generally _can_ assign a 
subtype to a supertype.

So maybe try an example like this without the `extends` stuff and see if the 
compiler chokes on it or not.

[ Full content available at: https://github.com/apache/kafka/pull/5273 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to