I have a class with constructor declared like this
class Facade<T : SuperClass>(
val kClass: KClass<in T> = SuperClass::class
)
It is done like this so that developer doesn't have to specify SuperClass if they want to use it instead of a subclass. Reason to even send the class type is, so that developer doesn't have to specify type in angle brackets .
But now comes the problem. Creating instance like below, says that there is not enough information to infer parameter T. Which is resulting in having to put class into angle brackets.
Facade()
But since default value is SuperClass, then kotlin should be able to infer parameter T as SuperClass. What am I thinking wrong?
Thank you
TL;DR:
Facade(SubClass:class) // working
Facade(SuperClass:class) // working, but don't want (superclass is default)
Facade<SuperClass>() // working, but don't want angle brackets <>
Facade() // not working, cannot infer T type from default, why?