Skip to content

Infer generics when doing pattern matching #55602

Open
@rrousselGit

Description

@rrousselGit

Hello!

It appears that currently, when we write:

class Generic<T> {
  final T value;
}

...
switch (Generic<int>()) {
  case Generic(:final value?):
}

then value is inferred as "dynamic". But in this context, T is guaranteed to be at least int

Would it be possible to consider case Generic(<...>) as case Generic<int>(<...>)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    cfe-dysfunctionalitiesIssues for the CFE not behaving as intendedfeature-patternsImplementation of the patterns featurelegacy-area-front-endLegacy: Use area-dart-model instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions