I have this abstract class which accepts an interface as generic type:
abstract class A<T: GenericInterface> : T {
...
}
The problem is that the compiler will not allow me to do this and will through this error:
Only classes and interfaces may serve as supertypes
Is it any workaround about this case?
I want my classes to extends the abstract class A passing a custom interface that extends GenericInterface and to be able to implement that custom interface methods.
This is the prototype of what I'm trying to achieve:
abstract class A<T: GenericInterface> : T {
...
}
interface CustomInterface: GenericInterface {
...
}
class B: A<CustomInterface> {
// Here I want to override CustomInterface funs
}
I know that I can always use this approach:
class B: A, CustomInterface {
// override CustomInterface funs here
}
but for code pattern purposes I would like the other solution