# Secondary constructur with JVM signature conflict

**URL:** https://discuss.kotlinlang.org/t/secondary-constructur-with-jvm-signature-conflict/17209
**Category:** Uncategorized
**Created:** [April 19, 2020, 4:07am UTC](https://discuss.kotlinlang.org/t/secondary-constructur-with-jvm-signature-conflict/17209 "2020-04-19T04:07:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![roland.schuetzig](https://avatars.discourse-cdn.com/v4/letter/r/82dd89/32.png) [@roland.schuetzig](https://discuss.kotlinlang.org/u/roland.schuetzig)
#### Post date: [April 19, 2020, 4:07am UTC](https://discuss.kotlinlang.org/t/secondary-constructur-with-jvm-signature-conflict/17209/1 "2020-04-19T04:07:17Z")

</div>

The following little code produces an error in IntelliJ IDEA.  
class A(fct1: (Int) → Float = {0.4f}) {  
constructor(fct2:(Int)-\>Unit) : this()  
}  
The compiler perceives fct1 and fct2 as a conflict, allthough they have different types (Int)-\>Float and (Int)-\>Unit respectively. Isn’t it the philosophy of Kotlin to take care for exactly that sort of thing? fct1 and fct2 are just different parameters.  
Any opinion?

---

<div class="post-metadata">

### Author: ![tieskedh](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tieskedh/32/2816_2.png) [@tieskedh](https://discuss.kotlinlang.org/u/tieskedh)
#### Post date: [April 19, 2020, 7:49am UTC](https://discuss.kotlinlang.org/t/secondary-constructur-with-jvm-signature-conflict/17209/2 "2020-04-19T07:49:55Z")

</div>

Maybe it works like this:

```
class A(...){
    companion object {
         operator fun invoke(...)= A()
    }
}

```

the reason it doesn’t work is that the return type of a lambda is a generic.  
Generics are changed to object during compile time.  
Therefor, both the lambda’s will return the same value: `Any?`.  
Therefor it’s not possible to have both at the same time.

With my solution, you will have two functions that are really different.  
That means that it’s now a question of kotlin is smart enough to create the correct match…  
**Update** : Kotlin can’t make the match (yet), even when inlining both.

---

<div class="post-metadata">

### Author: ![Beholder](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/beholder/32/2078_2.png) [@Beholder](https://discuss.kotlinlang.org/u/Beholder)
#### Post date: [April 19, 2020, 7:22pm UTC](https://discuss.kotlinlang.org/t/secondary-constructur-with-jvm-signature-conflict/17209/3 "2020-04-19T19:22:50Z")

</div>

I Java you can have very similar problem

```java
import java.util.function.Function;

public class A {
	public A(Function<Integer, Float> f) { }
	public A(Function<Integer, Void> f) { }
}

```

Error: ‘A(Function\<Integer, Float\>)’ clashes with ‘A(Function\<Integer, Void\>)’; both methods have same erasure
