Error on runtime with extension functions (Maybe for the lack of reified generics)


As part of the next version of funKTionale I'm implementing a flip extension function.

public fun<P1, P2, R> Function1<P1, Function1<P2, R>>.flip(): (P2) -> (P1) -> R {
    return {(p2: P2) -> {(p1: P1)  -> this(p1)(p2) } }

So far, so good, the IDE, compiler and tests works fine

Then I define my next flip extension function

public fun<P1, P2, P3, R> Function1<P1, Function1<P2, Function1<P3, R>>>.flip(): (P3) -> (P2) -> (P1) -> R {
    return {(p3: P3) -> {(p2: P2) -> {(p1: P1)  -> this(p1)(p2)(p3) } } }

The IDE is happy, also the compiler, but when I execute my tests

java.lang.ClassFormatError: Duplicate method name&signature in class file org/funktionale/flip/FlipPackage   at java.lang.ClassLoader.defineClass1(Native Method)   at java.lang.ClassLoader.defineClassCond(   at java.lang.ClassLoader.defineClass(   at   at   at$000(   at$   at Method)   at   at java.lang.ClassLoader.loadClass(   at sun.misc.Launcher$AppClassLoader.loadClass(   at java.lang.ClassLoader.loadClass(   at org.funktionale.flip.FlipTest.testFliping(FlipTest.kt:17)

Lack of reified generics? Bug on Kotlin runtime?


Bug in diagnostics: you are creating two functions with the same name and one parameter (receiver) of type Function1<...>. Their (erased) Java signatures are identical, which is forbidden.

Please report the bug to the tracker. Thanks