Jan Skrasek
05/07/2021, 1:34 PMinternal interface I {}
public class Exported {
protected val: I? = null
}
Why I cannot have protected property with internal type in FINAL class?
'protected (in Exported)' property exposes its 'internal' type I
The usecase is a public Fragment/Activity with internal ViewModel. We have this viewmodel property abstract in the fragment's parent -> therefore protected.Endre Deak
05/07/2021, 4:31 PMJan Skrasek
05/07/2021, 5:06 PMEndre Deak
05/07/2021, 5:08 PMinterface I
is internal. But if Exported
is public (and not final), it means that anyone could inherit, which - as the message suggests - leads to expose something internal to the public.Jan Skrasek
05/07/2021, 5:50 PMRoukanken
05/07/2021, 7:12 PMJan Skrasek
05/10/2021, 10:56 AMpublic interface ViewModel {
public fun doSomething()
}
public abstract class BaseActivity {
protected abstract val viewModel: ViewModel
}
internal class FinalViewModel : ViewModel {
override fun doSomething() {}
fun doSomethingElse() {}
}
public class FinalActivity : BaseActivity() {
protected override val viewModel: FinalViewModel = FinalViewModel()
}