Mam następujące klasy Hierarchia:Dlaczego klasa publiczna nie może rozszerzyć klasy prywatnej?
interface Repository
// This class contains some common stuff for LocalRepository and RemoteRepository. I'm never going to use this class outside this file, so I make it private
private abstract class BasicRepositoryImpl
// these classes are designed to be instantiated in other files
class LocalRepository : BasicRepositoryImpl(), Repository // error
class RemoteRepository : BasicRepositoryImpl(), Repository // error
Ale pojawia się następujący błąd:
Subclass effective visibility 'public' should be the same or less permissive than its superclass effective visibility 'private'
nie chcę używać BasicRepositoryImpl
gdziekolwiek indziej, więc to uznane private
, i chcę używać LocalRepository
i RemoteRepository
w innych plikach tak:
class Presenter(val repo: Repository)
val p = Presenter(LocalRepository())
ale zapobiega błędach mi stworzyć taką hierarchię. Czemu? Co jest z tym nie tak?