Kotlin / binary-compatibility-validator

Public API management tool
Apache License 2.0
828 stars 59 forks source link

Internal class ComposeSingletons is presented in the api dump #74

Open SumeraMartin opened 2 years ago

SumeraMartin commented 2 years ago

I'm using kotlin 1.5.31 with compose 1.0.5.

My api dump contains a lot of following classes

public final class cloud/jablotron/apps/lib/auth/oauth2/ui/screens/login/ComposableSingletons$LoginScreenKt {
    public static final field INSTANCE Lcloud/jablotron/apps/lib/auth/oauth2/ui/screens/login/ComposableSingletons$LoginScreenKt;
    public static field lambda-1 Lkotlin/jvm/functions/Function3;
    public static field lambda-2 Lkotlin/jvm/functions/Function2;
    public fun <init> ()V
    public final fun getLambda-1$library_release ()Lkotlin/jvm/functions/Function3;
    public final fun getLambda-2$library_release ()Lkotlin/jvm/functions/Function2;
}

I'm not sure whether the issue is in this library or in the compose.

After brief look at the compose code, I assume that these classes should be internal so they shouldn't be presented in the api dump. Since compose code is not generated and is not possible to take a look at the code. It is really hard to get rid of these. Do you think that the issue is in the library? Or do you have an idea how to get rid of it? https://github.com/androidx/androidx/blob/4356507bc51920e48d01612f4e6f69f907055456/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/LambdaMemoizationRegressionTests.kt

Thanks

qwwdfsad commented 2 years ago

Thanks for the report.

I'll try to figure out what this ComposeSingletons is and whether it actually constitutes public ABI and will return here with the news.

It may be the case that it should be fixed in Compose itself (e.g. by adding the corresponding internal modifier to metadata) or that it is part of the ABI

4brunu commented 2 years ago

Hi @qwwdfsad, I have the same problem. Any news on this? Thanks

qwwdfsad commented 2 years ago

Alas, no progress regarding this

ThatGuyPancake commented 2 months ago

@qwwdfsad is there any progress on this? It seems that all Previews in Compose get detected as public API because of this, even tho the function is marked as private :/

fzhinkin commented 2 months ago

@ThatGuyPancake nope, unfortunately there's no progress. I'll check what ComposableSingletons are.

fzhinkin commented 1 month ago

Seems like ComposableSingletons may actually constitute the public ABI of a library (it's not clear yet if that was intended), so at least now, it has to be included into dumps.

SumeraMartin commented 1 month ago

Any way to filter them out? Don't they have any kind of annotation? There is too many of them and it make a terrible mess of our api files. We have hundreds of them 🙈

Feature idea: add option to filter out based on custom method or regex?

fzhinkin commented 1 month ago

Don't they have any kind of annotation?

They don't. I'm afraid, the only available option right now is to explicitly enumerate all such classes as ignored, but that'll turn a build script into a mess.

ShikaSD commented 1 month ago

It seems like some ComposableSingletons have unintentionally escaped into public ABI, we are going to explicitly enumerate those with @PublishedApi in 2.1 and provide more stable names to avoid collisions.