Skip to content

[Static extensions] Can static extensions declare constructors with prefixed names? #4681

@leafpetersen

Description

@leafpetersen

The proposal for adding constructors to static extensions is currently (I believe) in a somewhat inconsistent state with respect to declaring constructors in extensions for which the on-declaration is a prefixed name. The text possibly implies that it may be possible to declare such a constructor using a prefixed name, however, I believe that the syntax does not yet support such a declaration, and also the text around invocations I believe would need some modification to account for this. Consider the following examples:

import "foo.dart" as f; // foo.dart declares a class named C and a class named f
import "foo.dart" show D; // foo.dart also declares a class named C

extension E1 on f.C {
  f.C.name(); // Is this a valid declaration of a constructor named `C.name`?
}

extension E2 on f.C {
  C.name(); // Is this a valid declaration of a constructor named `C.name`?
}

extension E2 on f.f {
  f.f(); // Is this a valid declaration of a constructor named `f.f`?  Or of a constructor named `f.new`?
}

extension E4 on D {
  f.D.name(); // Is this a valid declaration of a constructor named `D.name`?
}

What do we intend to support here?

cc @dart-lang/language-team

Metadata

Metadata

Assignees

Labels

static-extensionsIssues about the static-extensions feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions