Having a class:
abstract class Bird<T: Food>
and a subclass, where Fish
extends Food
:
class Falcon: Bird<Fish>()
How do I create a method that returns a Bird
:
fun getBird(type: Int): Bird<Food> {
if (type == SOME_CONSTANT) {
return Falcon()
} else {
// Another bird
}
}
Getting:
Type mismatch: Required Bird<Food>, found Falcon