https://kotlinlang.org logo
Title
c

Can Orhan

08/06/2018, 2:08 PM
Is there a way to construct a sealed class with referenced children? Something like
sealed class Seal {
    class InnerClass: Seal()
    ReferencedClass::class
}
k

karelpeeters

08/06/2018, 3:37 PM
So you want this to mean that
ReferencedClass
is a child of
Seal
?
c

Can Orhan

08/07/2018, 7:18 AM
Yup
k

karelpeeters

08/07/2018, 10:56 AM
Do you control
ReferencedClass
?
c

Can Orhan

08/07/2018, 10:57 AM
Yup
k

karelpeeters

08/07/2018, 10:57 AM
Then just move it into the sealed class file 😒imple_smile:
c

Can Orhan

08/07/2018, 10:58 AM
In the sealed class file or the sealed class scope?
Because the point of the question is to be able to not have n number of child definitions all in one place
k

karelpeeters

08/07/2018, 1:01 PM
You can put all child definition in the sealed class' file, right?
c

Can Orhan

08/07/2018, 1:20 PM
No. sealed class' init is private. I'm inclined to believe that what I want is not possible. Would be nice to know why, though.