When Sealed Classes is declared in inner class, the following error is shown
Cannot access '
': it is 'private' in 'ViewItem'
This type is sealed, so it can be inherited by only its own nested classes or objects
sealed class ViewItem(val resource: Int)class Image(val imageResource: String): ViewItem(R.layout.content_pin_list_item_image)class Property(val icon: Int?, val value: String): ViewItem(R.layout.content_pin_list_item)
The following declaration must be used for inner class.
class PinActivity : AppCompatActivity() { sealed class ViewItem(val resource: Int) { class Image(val imageResource: String): ViewItem(R.layout.content_pin_list_item_image) class Property(val icon: Int?, val value: String): ViewItem(R.layout.content_pin_list_item) }}
References: