In my concrete class I would like to have a function that has the following signature.
inline fun <reified T : Comparable<T>> get(key: String): T
However I want to extract an interface for this class so I could swap implementations. However I'm not sure how to go about it as I can't mark virtual
functions as inline
.
So far I have this interface:
interface ModuleSettings {
fun <T : Comparable<T>> get(key: String) : T
}
And this concrete class
class DefaultModuleSettings : ModuleSettings {
override inline fun <reified T : Comparable<T>> get(key: String): T {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
But now the compiler complains that im trying to override the generic type with reified
keyword. Is there any way I can achieve this pattern?