У меня есть два класса (AA
& BB
), которые наследуют с одной стороны случайный класс, а с другой стороны от одного и того же абстрактного класса, это выглядит так:
abstract class X {
// Only getters in this class
}
abstract class C {
// Only getters in here
}
class A extends X {
int randomField;
}
class B extends X {
int randomField;
}
class AA extends A with C {
int randomField;
}
class BB extends B with C {
int randomField;
}
final List<C> doesntCompile = [
new BB(),
new AA(),
new BB(),
];
Этокод выше говорит A value of type 'List<X>' can't be assigned to a variable of type 'List<C>'
Есть идеи, как решить эту проблему?