Lets say we have the following trait and class definition
trait Model extends Product
class X[T <: Model] {}
Give the above I can create instance of X as follows.
val x = new X
The compiler does not complain. The inferred type in this case is Nothing. I would like to know how can I prevent this at compile time so that it is not allowed to create instances of X without providing an explicit type i.e is a subtype of Model?
I think this works:
However you can still explicitly gives
Nothingas type-arg (strange...):I would go for the above, but an other idea is to explicitly pass as parameter the class of the Model subclass: