# Why return type of producer methods in projected generic types with upper bound is Any? instead of upper bound type?

**URL:** https://discuss.kotlinlang.org/t/why-return-type-of-producer-methods-in-projected-generic-types-with-upper-bound-is-any-instead-of-upper-bound-type/17156
**Category:** Language Design
**Created:** [April 16, 2020, 11:11am UTC](https://discuss.kotlinlang.org/t/why-return-type-of-producer-methods-in-projected-generic-types-with-upper-bound-is-any-instead-of-upper-bound-type/17156 "2020-04-16T11:11:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Ehsan](https://avatars.discourse-cdn.com/v4/letter/e/96bed5/32.png) [@Ehsan](https://discuss.kotlinlang.org/u/Ehsan)
#### Post date: [April 16, 2020, 11:11am UTC](https://discuss.kotlinlang.org/t/why-return-type-of-producer-methods-in-projected-generic-types-with-upper-bound-is-any-instead-of-upper-bound-type/17156/1 "2020-04-16T11:11:14Z")

</div>

I asked this question [here](https://stackoverflow.com/questions/61231708/why-return-type-of-producer-methods-in-projected-generic-types-with-upper-bound) on Stack Overflow and didn’t get any answer.

Consider this setup:

```auto
open class Base
open class Derived: Base()

interface Foo<T: Base> {
    fun produce(): T
    fun consume(aT: T)
}

```

Following functions are valid:

```auto
fun apply1(f: Foo<*>) {
    val p: Base = f.produce();
}

fun apply2(f: Foo<Derived>) {
    val p: Base = f.produce();
}

```

but this one is not:

```auto
fun apply3(f: Foo<in Derived>) {
    val p: Base = f.produce();
}

```

> Type mismatch  
> Required: Base  
> Found: Any?

Generic type parameter `T` has an upper bound. So it could be safely considered as a sub type of `Base` as it is done in `apply1` and `apply2` . The question is why it is not valid to do the same when it is projected with `in` ?
