Skip to content

public members of non-API supertype should be visible in the inheritor #217

@dovchinnikov

Description

@dovchinnikov

Example 1

@PrivateApi
class KtPrivateApi {
  fun foo() = Unit
}

class KtPublicApi : KtPrivateApi() {
}

fun usage() {
  KtPublicApi().foo() // ok, if @PrivateApi applies only for the class declaration but not its members
}

Example 2

This is not applicable for Kotlin, but should be supported in a library, which has compiled classes as input.

class JavaPackagePrivateClass { 
    public void foo() {} 
}
public class JavaPublicClass extends JavaPackagePrivateClass {
  
}

void usage() {
  new JavaPublicClass().foo(); // accessible 
}

For IJ, I've implemented this here:
https://github.com/JetBrains/intellij-community/blob/f8819a2580a0cc6c2f6a456a6a5fa83bf2e3cf7e/tools/apiDump/src/impl.kt#L134

Also please take a look at supertype expansion:
https://github.com/JetBrains/intellij-community/blob/f8819a2580a0cc6c2f6a456a6a5fa83bf2e3cf7e/tools/apiDump/src/impl.kt#L340
It solves this problem:

// not covered the case when there is public superclass after chain of private superclasses

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions