# Problem calling overloaded functions with function parameters

**URL:** <https://discuss.kotlinlang.org/t/problem-calling-overloaded-functions-with-function-parameters/950>\
**Category:** Uncategorized\
**Created:** [January 9, 2013, 4:20pm UTC](https://discuss.kotlinlang.org/t/problem-calling-overloaded-functions-with-function-parameters/950 "2013-01-09T16:20:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saltnlight5](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/saltnlight5/32/1525_2.png) [@saltnlight5](https://discuss.kotlinlang.org/u/saltnlight5)\
**Post date:** [January 9, 2013, 4:20pm UTC](https://discuss.kotlinlang.org/t/problem-calling-overloaded-functions-with-function-parameters/950/1 "2013-01-09T16:20:44Z")

</div>

Hi,

The following fail to compile with **Overload resolution ambiguity: internal final fun Foo.repeat(n : jet.Int, block : () -\> Unit) : Unit defined in root package internal final fun Foo.repeat(n : jet.Int, block : (jet.Int) -\> Unit) : Unit defined in root package**

```kotlin
class Foo
fun Foo.repeat(n : Int, block: ()->Unit) {
     for (i in 1 .. n)
          block()
}
fun Foo.repeat(n : Int, block: (Int)->Unit) {
     for(i in (1 .. n))
          block(i)
}

fun main(args : Array<String>) {
     Foo().repeat(3){ println(“test”) }          // case 1
     Foo().repeat(3){ i -> println(“test $i”) }  // case 2
}
```

What’s is interesting is that if I comment out just the “case 1” line, the program will run “case 2” without problem.

So the question I have is overloaded functions that has function as parameter officially supported? If yes, this would be a bug then?

Thanks,  
Zemian

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [January 9, 2013, 6:31pm UTC](https://discuss.kotlinlang.org/t/problem-calling-overloaded-functions-with-function-parameters/950/2 "2013-01-09T18:31:59Z")

</div>

This is a bug. A workaround is to explicitly specify parameters in function literals.

Please, report to the tracker. Thanks

---

<div class="post-metadata">

**Author:** ![saltnlight5](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/saltnlight5/32/1525_2.png) [@saltnlight5](https://discuss.kotlinlang.org/u/saltnlight5)\
**Post date:** [January 9, 2013, 8:07pm UTC](https://discuss.kotlinlang.org/t/problem-calling-overloaded-functions-with-function-parameters/950/3 "2013-01-09T20:07:47Z")

</div>

[http://youtrack.jetbrains.com/issue/KT-3212](http://youtrack.jetbrains.com/issue/KT-3212)
