It doesn’t look like your sample code would ever compile, because you’re not providing a type parameter to mutableListOf. How does the compiler know what the type of internal var list is? Right now it’d just be List with no type.
There seems to be a formatting problem due to angle brackets <>. I was able to get the original text of the post using Discourse’s raw API, but OP, please use code formatting using triple backticks ``` next time
class GenericClass<T> {
@PublishedApi internal var list = mutableListOf<String>()
companion object {
inline fun <reified T : Any> GenericClass<T>.init() {
list = mutableListOf() // compiler error accessing list, only fails for setting, not getting
}
}
}
I can’t seem to reproduce the compiler error though, at least on 2.0.21