Foo is final, I dont get it
# getting-started
u
Foo is final, I dont get it
No it doesnt because generic param is not part of any public api, that is exactly what confuses me. Callsite cant see Quax in any form
unless im missing something
basically its this
Copy code
class FooFragment : BaseFragment<FooViewMode> {

	override fun onCreateViewModel() {
		return FooViewModel()
	}
}

class BaseFragment<T> {
	protected lateinit var viewModel: T

	override fun onCreateView(view: View) { <-- framework
		viewModel = onCreateViewModel()
	}

	protected abstract fun onCreateViewModel() : T
}
i.e. FooViewModel is implementation detail of FooFragment, I see no reason to expose it publicly; viewModel reference is protected inside BaseFragment hierarchy..idk
how? its protected
You cant, im trying it right now
Compilers dont understand visibility?
isnt this some sort of javainterop bs? I think protected is also package private in java
I dont get it what you mean, if it gets change to public it wont compile, same how if private function returns a private class, and you change it to public it wont compile
im still not sure why does the param need to be public, im trying even simpler example
Copy code
class Bar : Foo<Quax>() 

abstract class Foo<T>

internal class Quax
error is
public sublcass exposes internal supertype argument
Btw it works in java with package private T_T
Copy code
public class Rah extends Meh<Ohe> {
}

class Ohe {
}

abstract public class Meh<T> {
}
this is precisely what I want in kotlin (swap package private for internal)
it only complains if Ohe is private (nested)