Kotlin / binary-compatibility-validator

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

Interface DefaultImpls classes are present in API files even though the interface is annotated with OptIn and the annotation excluded #155

Closed arkivanov closed 6 months ago

arkivanov commented 7 months ago

Reproducer code:

@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
@Retention(AnnotationRetention.BINARY)
annotation class InternalApi

@InternalApi
interface Foo {
    fun foo() {}
}

Also excludle InternalApi annotation using nonPublicMarkers config.

As expected, the Foo interface is not present in API files, but its DefaultImpls class is.

public final class com/arkivanov/mvikotlin/core/utils/Foo$DefaultImpls {
    public static fun foo (Lcom/arkivanov/mvikotlin/core/utils/Foo;)V
}

public abstract interface annotation class com/arkivanov/mvikotlin/core/utils/InternalApi : java/lang/annotation/Annotation {
}

Perhaps, DefaultImpls should be also excluded in this case?

fzhinkin commented 7 months ago

Thanks for reporting the issue. It actually seems to be a bug.