# Problem with Type mismatch for generic type extending another generic type

**URL:** <https://discuss.kotlinlang.org/t/problem-with-type-mismatch-for-generic-type-extending-another-generic-type/12138>\
**Category:** Support\
**Created:** [March 28, 2019, 11:17am UTC](https://discuss.kotlinlang.org/t/problem-with-type-mismatch-for-generic-type-extending-another-generic-type/12138 "2019-03-28T11:17:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mriegler](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mriegler](https://discuss.kotlinlang.org/u/mriegler)\
**Post date:** [March 28, 2019, 11:17am UTC](https://discuss.kotlinlang.org/t/problem-with-type-mismatch-for-generic-type-extending-another-generic-type/12138/1 "2019-03-28T11:17:13Z")

</div>

Hi,  
for context, I’m trying to write a Apache Beam job that writes to Kafka using Kotlin. The KafkaIO package has some example code I’m trying to convert to Kotlin ([under Reading Kafka Topics](https://beam.apache.org/releases/javadoc/2.0.0/org/apache/beam/sdk/io/kafka/KafkaIO.html).

This works fine, until the last line, in Java being:

```
.apply(Values.<String>create())

```

writing this in Kotlin as

```
.apply(Values.create<String>())

```

gives me a type mismatch error.

```
Error:(24, 13) Kotlin: Type mismatch: inferred type is Values<String!>! but PTransform<in PCollection<KafkaRecord<Long!, String!>!>!, PCollection<String!>!>! was expected

```

But Values\<String!\>! should be a subclass of PTransform. Here’s its Javadoc: [Values (Apache Beam 2.5.0)](https://beam.apache.org/releases/javadoc/2.5.0/org/apache/beam/sdk/transforms/Values.html)

I don’t understand why this works in Java, but not in Kotlin. What with it being a million generics deep type, there’s probably an issue there, but type stuff has always been my weak point. Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![mriegler](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mriegler](https://discuss.kotlinlang.org/u/mriegler)\
**Post date:** [March 28, 2019, 2:40pm UTC](https://discuss.kotlinlang.org/t/problem-with-type-mismatch-for-generic-type-extending-another-generic-type/12138/2 "2019-03-28T14:40:14Z")

</div>

The issue has been resolved. One of the optional methods in the example creates a PCollection instead of a collection of KafkaRecords. That fixed it. Reading helps
