# Kotlin function type inference

**URL:** <https://discuss.kotlinlang.org/t/kotlin-function-type-inference/881>\
**Category:** Uncategorized\
**Created:** [March 22, 2013, 8:42am UTC](https://discuss.kotlinlang.org/t/kotlin-function-type-inference/881 "2013-03-22T08:42:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![steamstreet](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/steamstreet/32/1529_2.png) [@steamstreet](https://discuss.kotlinlang.org/u/steamstreet)\
**Post date:** [March 22, 2013, 8:42am UTC](https://discuss.kotlinlang.org/t/kotlin-function-type-inference/881/1 "2013-03-22T08:42:49Z")

</div>

I'd like to create a function like this:

fun doSomething(vararg options: Pair\<String, ()-\>Unit\>) {

})

and call it like this:

doSomething(

&nbsp;&nbsp;"a" to {

&nbsp;&nbsp;},

&nbsp;&nbsp;"b" to {

&nbsp;&nbsp;}

)

Unfortunately, the compiler complains:

Kotlin: Type inference failed: Not enough information to infer parameter B in fun \<A, B\> A.to(that : B) : kotlin.Pair\<A, B\> Please specify it explicitly.

Is there no way to do this? I figured that since the call target specified the types that the type inference of the ‘to’ function would work.

---

<div class="post-metadata">

**Author:** ![steamstreet](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/steamstreet/32/1529_2.png) [@steamstreet](https://discuss.kotlinlang.org/u/steamstreet)\
**Post date:** [March 22, 2013, 8:48am UTC](https://discuss.kotlinlang.org/t/kotlin-function-type-inference/881/2 "2013-03-22T08:48:30Z")

</div>

Ok, I'm starting to think this is a bug, because this works:

val aFunc = {

}

val bFunc = {

}

doSomething(

&nbsp;&nbsp;"a" to aFunc,

&nbsp;&nbsp;"b" to bFunc

);

I’m not sure why inlining the functions should change anything.

I have logged a bug: [http://youtrack.jetbrains.com/issue/KT-3435](http://youtrack.jetbrains.com/issue/KT-3435)

---

<div class="post-metadata">

**Author:** ![bashor](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/bashor/32/1431_2.png) [@bashor](https://discuss.kotlinlang.org/u/bashor)\
**Post date:** [March 22, 2013, 10:25am UTC](https://discuss.kotlinlang.org/t/kotlin-function-type-inference/881/3 "2013-03-22T10:25:01Z")

</div>

All right, it's bug. Thanks.
