eygraber
02/14/2023, 6:25 PMprotected
and internal
visibility? Pretty sure the answer is no, but just checking. Are there any proposals for adding something like that?
Use case is where I want to invoke an abstract function from a class in the same module, and have subclasses implement them.Adam S
02/14/2023, 6:32 PMephemient
02/14/2023, 6:42 PMabstract class Foo {
abstract protected fun foo()
companion object {
internal fun Foo.foo() = foo()
}
}
import Foo.Companion.foo
super ugly, but assuming this is what you mean by "union"… this will allow internal
, non-derived callers to use the extension Foo.foo
, while derived callers use can use the protected foo
.eygraber
02/14/2023, 6:52 PMYoussef Shoaib [MOD]
02/15/2023, 10:19 AMabstract class Foo {
abstract protected fun foo()
final internal fun foo(unit: Unit = Unit) = this.foo()
}
(Haven't tested it out but I think it should work) it's slightly neater in that no import is required at the call site, but the unit parameter (which is needed for disambiguation) is annoying.