I don't really know what's going on here, and I doubt any of this code should be written in the first place, but the inconsistency that's occasionally printing B seems wrong. Or maybe it's intentional. I'm honestly not sure at this point.
class ReportA {
void Report() const { print("A"); }
}
class ReportB : ReportA {
void Report() const override { print("B"); }
}
void main() {
array<ReportA> startWithConstructorA = {ReportA()};
startWithConstructorA[0].Report(); //A
startWithConstructorA = {ReportB()};
startWithConstructorA[0].Report(); //A
startWithConstructorA.insertAt(0, ReportB());
startWithConstructorA[0].Report(); //A
array<ReportA> startWithConstructorB = {ReportB()};
startWithConstructorB[0].Report(); //B
startWithConstructorB = {ReportB()};
startWithConstructorB[0].Report(); //B
startWithConstructorB.insertAt(0, ReportB());
startWithConstructorB[0].Report(); //A
ReportB variableB;
array<ReportA> startWithVariableB = {variableB};
startWithVariableB[0].Report(); //A
startWithVariableB = {variableB};
startWithVariableB[0].Report(); //A
startWithVariableB = {ReportB()};
startWithVariableB[0].Report(); //A
startWithVariableB.insertAt(0, variableB);
startWithVariableB[0].Report(); //A
startWithVariableB.insertAt(0, ReportB());
startWithVariableB[0].Report(); //A
}
As well as:
array<ReportA> insert0 = {ReportB()};
insert0.insertAt(0, ReportB());
insert0 = {variableB}; //fine
array<ReportA> insert1 = {ReportB()};
insert1.insertAt(1, ReportB());
insert1 = {variableB}; //An exception 'Mismatching types in value assignment' occurred.