Kotlin/KEEP

KMP Kotlin-to-Java direct actualization

nikitabobko opened this issue · 4 comments

This issue is for discussion of the proposed Kotlin-to-Java direct actualization. The full text of the proposal is here.

PR: #392

I'm a little unclear whether @KotlinActual annotations will be needed on methods and nested classes of classes that have that annotation? So for instance:

// COMMON
expect class Foo {
  fun bar()

  class Quux {}
}
@KotlinActual
public class Foo {
    @KotlinActual // (1) needed?
    public void bar() {...}

    public void baz() {...}

    @KotlinActual // (2) needed?
    public static class Quux {}
}

It would seem tedious to have to annotate (1) in particular, i.e., every method corresponding to a declaration in the expected class.

I'm a little unclear whether @KotlinActual annotations will be needed on methods and nested classes of classes that have that annotation?

Yes, both (1) and (2) will be needed. @KotlinActual in Java works similarly to actual keyword in Kotlin

It would seem tedious to have to annotate (1) in particular, i.e., every method corresponding to a declaration in the expected class.

I understand the concern. I agree that initially, it will be harder to commonize existing Java classes, but hopefully @KotlinActual will help in the long run with the error prevention and library maintenance https://github.com/Kotlin/KEEP/blob/kotlin-to-java-direct-actualization/proposals/kmp-kotlin-to-java-direct-actualization.md#actual-keyword-is-a-virtue

It's appealing to me that the annotation resembles actual keyword behavior