Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referencing members from companion objects of base class #3749

Open
fedochet opened this issue Aug 16, 2024 · 0 comments
Open

Referencing members from companion objects of base class #3749

fedochet opened this issue Aug 16, 2024 · 0 comments
Labels
kdoc-spec An issue that requires clarification from the KDoc spec's perspective

Comments

@fedochet
Copy link

Hi!

Should it be possible to reference members of companion objects from the base classes of the current class?

For example:

/**
 * [fromCompanion] - seems correct
 */
open class Base {
  companion object {
    fun fromCompanion(): Int = 10
  }
}

/**
 * [fromCompanion] - ???
 */
class Child : Base() 

A clarification: companion objects from base classes are present as implicit receivers in the child classes. The following code is valid, for example:

class Child(val prop: Int = /*Base.Companion.*/fromCompanion()) : Base() 
@fedochet fedochet added the kdoc-spec An issue that requires clarification from the KDoc spec's perspective label Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kdoc-spec An issue that requires clarification from the KDoc spec's perspective
Projects
None yet
Development

No branches or pull requests

1 participant