Closed
Description
Consider the following program:
class Base {
void foo() {
print('Base.foo called');
}
}
class M1 {
void foo({x}) {
print('M1.foo called, with x=$x');
}
}
class BaseWithM1 = Base with M1;
class M2 {
void foo() {
print('M2.foo called');
}
}
class Derived extends BaseWithM1 with M2 {}
main() {
new Derived().foo();
}
I'm not certain what the behavior of this program should be, but I think it should be either:
- Undefined due to an error (since the mixin application
BaseWithM1 with M2
attempts to overridefoo({x})
withfoo()
, and overrides may not drop optional parameters. - Prints
M2.foo called
.
If I run this under the VM, it reports no errors and prints M1.foo called, with x=null
. That seems definitely wrong. So even though I'm not certain what the correct behavior should be I'm filing this as a VM bug. Feel free to reclassify if I'm wrong about this.
Note that this is a reduction of a situation arose in practice during development of the analyzer/front_end integration. The actual classes/methods involved were:
Base
->Generator
M1
->KernelExpressionGenerator
BaseWithM1
->KernelGenerator
M2
->ContextAwareGenerator
Derived
->KernelContextAwareGenerator
foo
->buildCompoundAssignment
I'll shortly upload a CL that modifies the parameters of buildCompoundAssignment
to work around this issue.
Cc @leafpetersen, @eernstg, and @lrhn to weigh in on what the correct behavior should be.