I need to prevent other classes from instantiating the
Child
a
aarjav
01/12/2019, 11:31 PM
maybe you can just use an interface and discourage instantiating it directly?
Copy code
class Parent {
companion object {
fun foo(): Child = Us("field" )
}
interface Child {
val field: String
}
private data class Us(override val field: String) : Child
}