Marc Knaup
11/18/2020, 5:16 PMINCONSISTENT_TYPE_PARAMETER_VALUES
error (in K/JS)?
I have hundreds of Variable<T>
subinterfaces and want to re-use a single class that implements all of them.
That class would have different value for T
in its hierarchy but it’s only used internally and has no members that actually use T
.
interface Variable<T>
interface IntVariable : IntValue, Variable<Int>
interface StringVariable : StringValue, Variable<String>
interface IntValue
interface StringValue
@Suppress("INCONSISTENT_TYPE_PARAMETER_VALUES")
internal class GenericVariable : Variable<Any>, IntVariable, StringVariable
fun anyVariable(): Variable<Any> = GenericVariable()
fun intVariable(): Variable<Int> = GenericVariable()
fun stringVariable(): Variable<String> = GenericVariable()