Kotlin / binary-compatibility-validator

Public API management tool
Apache License 2.0
759 stars 55 forks source link

@JvmOverloads doesn't generate different methods for compose functions #213

Closed diklimchuk closed 3 months ago

diklimchuk commented 3 months ago

If i create a composable with @JvmOverloads annotation:

@JvmOverloads
@Composable
public fun Test(
    x: Int,
    y: String = "",
): Unit = Unit

the task apiDump generaties a single method instead of two different overloads of the same method:

public final class com/vk/id/onetap/compose/onetap/TmpKt {
    public static final fun Test (ILjava/lang/String;Landroidx/compose/runtime/Composer;II)V
}

If the same is run without @Composable annotation the task correctly dumps two methods into the api file

fzhinkin commented 3 months ago

@diklimchuk, it seems like once the Compose compiler plugin transformed @Composable functions, there are no default args anymore, so @JvmOverloads has no effect. You can check compiled classfiles to ensure that overloads were not included in the dump because they don't exist.

diklimchuk commented 3 months ago

Thank you, this resolves my problem