Closed
Description
The comment on ConstructorDeclaration.redirectedConstructor
(public API) says:
The type of object being created.
This can be different than the type in which the constructor is being
declared if the constructor is the implementation of a factory
constructor.
I'm not sure if that was ever true, but it isn't true now. (It'd be a cool feature.)
This code:
class C {
factory D C.foo() {
return D();
}
}
class D implements C {}
results in several errors, among them:
The name of a factory constructor must be the same as the name of the immediately enclosing class.
And this code:
class C {
D factory C.foo() {
return D();
}
}
class D implements C {}
results in one error:
Factory constructors cannot have a return type.
Looking at the call sites of ConstructorDeclarationImpl, the value of returnType
is always a SimpleIdentifier for the type name, in either a named or unnamed constructor.