user6744982
user6744982

Reputation:

Kotlin generate generic java code

I have an interface in kotlin, which looks something like this

interface BaseDao<in M : Model> {

    ...

    @Delete
    fun delete(models: Collection<M>)

    ...

}

Now when I look at the generated code I see something like this:

public interface BaseDao {

    ...

    @Delete
    void delete(@NotNull Collection var1);

    ...

}

Is there a way to tell kotlin that I want the type of the collection explicitly set?

Upvotes: 3

Views: 157

Answers (1)

nhaarman
nhaarman

Reputation: 100358

The 'generated code' is actually compiled byte-code decompiled to Java. And since generic types are lost due to type erasure, you will see plain Collection.

When working with the code from Java, the function still enforces the correct types.

Upvotes: 4

Related Questions