Sealed classes inside another class in Kotlin can't be compiled: cannot access '<init>' it is private
问题 If I used the example from the docs, class SomeActivity : AppCompatActivity() { sealed class Expr data class Const(val number: Double) : Expr() data class Sum(val e1: Expr, val e2: Expr) : Expr() object NotANumber : Expr() } it does not compile, with the error: Cannot access '<init>', it is private in 'Expr'. However, moving it outside the enclosing class makes it compile: sealed class Expr data class Const(val number: Double) : Expr() data class Sum(val e1: Expr, val e2: Expr) : Expr()