https://kotlinlang.org logo
Title
i

Ive Vasiljevic

12/26/2019, 4:40 PM
Is there any difference between nested sealed sub-classes and not nested sub-classes except for the way sub-classes are accessed?
t

tseisel

12/26/2019, 11:16 PM
AFAIK there is no difference. Historically sealed subclasses were only allowed when nested. This limitation was later removed to allow subclasses to be defined in the same file, for convenience.
k

kyleg

12/28/2019, 10:17 PM
Non-nested interact differently with the parent class’s init block, but I can’t remember the details. All I know is weeks ago I was getting some error regarding accessing parent
init
for non-nested, but when I made it a nested sealed class instead, the error went away.
t

tseisel

12/29/2019, 10:43 AM
@kyleg That's a rather strange behavior. Would you mind sharing the code that failed ? It may be a bug.
k

kyleg

12/30/2019, 7:48 PM
I don’t think I can. I ran into this weeks ago and definitely have refactored since. I think I was trying to do some sealed class stuff related to JB Exposed tables or entities.