Description
Please see Dart language specification 10.7.2 Factories
Assume that C<X1 extends B1 . . . , Xm extends Bm> is the name and
formal type parameters of the enclosing class, const? is const or empty, N
is C or C.id0 for some identifier id0, and id is an identifier, then consider a
declaration of a redirecting factory constructor k of one of the forms
const? factory
N(T1 x1 . . . , Tn xn, [Tn+1 xn+1=d1, . . . , Tn+k xn+k=dk]) = R;
const? factory
N(T1 x1 . . . , Tn xn, {Tn+1 xn+1=d1, . . . , Tn+k xn+k=dk}) = R;
where R is of one of the forms T<S1 . . . , Sp> or T<S1 . . . , Sp>.id. R
...
Otherwise, the redirectee constructor for this declaration is the constructor k′ denoted by R.
...
It is a compile-time error if a formal parameter of k′ has a default value
whose type is not a subtype of the type annotation on the corresponding formal
parameter in k.
But the example below has no expected error nor in analyzer nor in CFE
const num pi = 3.14 as num;
class F {
factory F(int x, [int y]) = C;
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
class C implements F {
C(int x, [num y = pi]) {}
}
main() {
F(42); // no error
}
Tested on Dart SDK version: 3.3.0-107.0.dev (dev) (Wed Nov 8 04:03:03 2023 -0800) on "windows_x64"