# Method overloading type resolution for passing lambda type

**URL:** https://discuss.kotlinlang.org/t/method-overloading-type-resolution-for-passing-lambda-type/24553
**Category:** Support
**Created:** [April 6, 2022, 8:18pm UTC](https://discuss.kotlinlang.org/t/method-overloading-type-resolution-for-passing-lambda-type/24553 "2022-04-06T20:18:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![gabriel.duncan](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@gabriel.duncan](https://discuss.kotlinlang.org/u/gabriel.duncan)
#### Post date: [April 6, 2022, 8:18pm UTC](https://discuss.kotlinlang.org/t/method-overloading-type-resolution-for-passing-lambda-type/24553/1 "2022-04-06T20:18:41Z")

</div>

Not sure if this is a compiler bug but the following pattern leads to method resolution error messages:

```auto
fun foo(getter: (Email) -> User, block: (User) -> Unit) = // function body that uses the getter and then calls the block with the result

class Getter {
    fun by(email: Email): User
    fun by(id: Id): User
}

val getterInstance = Getter()
foo(getterInstance::by) {...} // ERROR method signature can't be resolved

```

I’m curious why the compiler can’t figure out how to resolve the method signature given that the function taking it has a type that matches the `fun by(email: Email): User` signature.

what am i missing here?

---

<div class="post-metadata">

### Author: ![broot](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@broot](https://discuss.kotlinlang.org/u/broot)
#### Post date: [April 6, 2022, 8:52pm UTC](https://discuss.kotlinlang.org/t/method-overloading-type-resolution-for-passing-lambda-type/24553/2 "2022-04-06T20:52:55Z")

</div>

What version of Kotlin? It should work: [Kotlin Playground: Edit, Run, Share Kotlin Code Online](https://pl.kotl.in/mgzAhBYKs)

---

<div class="post-metadata">

### Author: ![gabriel.duncan](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@gabriel.duncan](https://discuss.kotlinlang.org/u/gabriel.duncan)
#### Post date: [April 7, 2022, 4:31am UTC](https://discuss.kotlinlang.org/t/method-overloading-type-resolution-for-passing-lambda-type/24553/3 "2022-04-07T04:31:22Z")

</div>

thanks for your reply, it is much appreciated. this is very strange because it works in the playground. i need to look back at my code and figure out what is different from my toy example. i think there might be another layer of indirection in the real code this is based off. i will update with that soon.
