Skip to content

Patterns destructing functions are colored the same as getters #59976

Closed
@FMorschel

Description

@FMorschel

Today the colouring for geters and methods is different. See the following code:

class Class {
  void Function() get getter => () {};
  void method() {}
}

void foo() {
  var instance = Class();
  instance.getter;
  instance.method;
}

This differenciates both in declaration and on usage even tough both of the above work the same*.


Today we have patterns that allow us to deconstruct a variable:

class Class {
  int myField = 0;
}

void foo() {
  var instance = Class();
  if (instance case Class(myField: var myFieldValue)) {}
}

We also can get** a method as a FunctionType:

class Class {
  int foo(int x) => x;
}

void bar() {
  var instance = Class();
  if (instance case Class(foo: var fooFn)) {
    fooFn(3);
  }
}

I'd like to request the same colouring to be applied here inside pattern destruction - at least when we have the name before : but I'd be fine with it also being applied to the new variable here if it has the same name.


*I've opened dart-lang/language#4159 related to this propriety.
**1. I've opened dart-lang/language#4234 related to this functionality.

**2. @lrhn has commented the following:

We also can get a method as a FunctionType:

Not absolutely sure that's intended, but will have to check the future specification to be sure whether it's allowed by that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestlegacy-area-analyzerUse area-devexp instead.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions