In my package `a.b.c`, I have an `abstract` class ...
# announcements
a
In my package
a.b.c
, I have an
abstract
class named
BaseUser
which I use it to share some code. But I want this class
BaseUser
to be internal in the
a.b.c
. Such that, I can create
User:BaseUser
in
a.b.c
. But the user of package can’t refer
a.b.c.BaseUser
. I tried the
protected
modifier. Not work, when I try to build, it said
This type is final, so it cannot be inherited from
,
Cannot access 'BaseUser': it is protected in 'a.b.c'
and
'public' subclass exposes its 'protected (in ?)' supertype BaseUser
. No luck with
internal
too How to make this work? 🤔
g
you cant make this work like your thinking, if you make object X public, then its entire superclass tree must also be public in kotlin
😢 1
a
Thanks.
g
Use composition instead of inheritance to dothat
a
@gildor Thanks. More hints for this? 😄
g
Do not extend class, but create an instance of private class inside of your public class and delegate method calls