Closed
Description
- 2.0.0-dev.68.0
- linux_x64
- DDC on Chrome
class Foo extends BaseFoo {
// Good!
static staticConstructor() => new Foo();
Foo.redirectingConstructor() : this();
Foo();
// Bad! `x` will always be null for toString([String x]);
// Behavior is always correct in VM\Flutter and Dart2JS
factory Foo.factoryConstructor() => new Foo();
@override String toString([String x]) => 'str: $x';
// these always work
String toStringFoo([String x]) => 'foo: $x';
@override String tooFoo([String x]) => 'coo: $x';
}
// Test to see if it applies to any override
class BaseFoo {
String tooFoo() => 'base!';
}
Expectation: This code will not throw.
var foo = test.Foo.factoryConstructor();
assert(foo.toString('foo') == 'str: foo');
Reality: This code will throw.
Any ideas?
I suppose for Dart 2, all factory constructors could be replaced with static constructors, but I don't like that.