Skip to content

[CFE] Provide a normal body for redirecting factory constructors #41915

Closed
@alexmarkov

Description

@alexmarkov

Currently redirecting factory constructors are encoded in a special way in the kernel AST:

    static field dynamic _redirecting# = <dynamic>[tes::A::foo];
    static factory icon() → tes::A*
      let dynamic #redirecting_factory = tes::B::• in invalid-expression;

This body contains a tear-off of a target constructor and invalid expression. In this form it cannot be handled as any other factory by back-ends so it is skipped or handled specially.

It would be useful for back-ends if CFE would actually provide a normal body for redirecting factory constructors: with a StaticCall to a target factory or a ConstructorInvocation of a target generative constructor.

This would help to avoid special casing redirecting factory constructors in certain places. We can also unskip them in the VM and support calling them from Dart C API and mirrors (#33041).

Related: #28424, #28421.

/cc @johnniwinther @mkustermann

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions