Skip to content

Enum shorthands using a type alias and invoking a constructor #4183

@eernstg

Description

@eernstg

Consider the following program, which assumes https://github.com/dart-lang/language/blob/main/working/3616%20-%20enum%20value%20shorthand/proposal-simple-lrhn.md:

class A<X> {
  final X x;
  A(this.x);
  AIntAlias get aInt => A(25);
}

typedef AIntAlias = A<int>;

void main() {
  AIntAlias _ = .new('Hello!').aInt;
}

The meaning of .new('Hello!').aInt is AIntAlias.new('Hello!').aInt, which is a compile-time error.

I think we would want to add a few words to the spec saying that the context type is subjected to a full alias expansion before we attempt to strip off the actual type arguments and re-compute them by inference.

@dart-lang/language-team, do you see any reason not to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    brevityA feature whose purpose is to enable concise syntax, typically expressible already in a longer formdot-shorthandsIssues related to the dot shorthands feature.questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions