In the DDC, when a mixin introduces a setter that overrides a private field, that setter is called unexpectedly during object initialization.
This seems to happen because the class is attempting to initialize the property backing that field to null, but ends up going through the setter instead unexpectedly.
This affects over_react, and we currently have a less-than-ideal workaround in place for this bug.
Reduced test case:
main() {
// Prints "_privateVar setter called" unexpectedly.
new C();
}
class A {
var _privateVar;
}
mixin B on A {
@override
get _privateVar {
print('_privateVar getter called');
}
@override
set _privateVar(value) {
print('_privateVar setter called');
}
}
class C extends A with B {}
This happens with both the new and old mixin syntax.
This does not happen:
- in dart2js
- when the field is public
- when the setter overrides occurs via a subclass
Reproducible in Dart SDK 2.2.0/2.2.1-dev.1.0
In the DDC, when a mixin introduces a setter that overrides a private field, that setter is called unexpectedly during object initialization.
This seems to happen because the class is attempting to initialize the property backing that field to
null, but ends up going through the setter instead unexpectedly.This affects over_react, and we currently have a less-than-ideal workaround in place for this bug.
Reduced test case:
This happens with both the new and old mixin syntax.
This does not happen:
Reproducible in Dart SDK 2.2.0/2.2.1-dev.1.0