Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension getter/setter prevents error from being reported for missing setter/getter on function type #57002

Open
stereotype441 opened this issue Oct 31, 2024 · 1 comment
Assignees
Labels
analyzer-spec Issues with the analyzer's implementation of the language spec area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.

Comments

@stereotype441
Copy link
Member

stereotype441 commented Oct 31, 2024

The analyzer accepts the following code, but the CFE rejects it:

extension on Object? {
  int get foo => 0;
}

test(void Function() f) {
  f.foo = 0; // ERROR
}

The CFE is correct in rejecting the code; there is no .foo= setter defined for the type void Function().

A similar thing happens with the roles of the getter and setter reversed. Again, the analyzer accepts the code, but the CFE rejects it:

extension on Object? {
  set foo(int value) {}
}

test(void Function() f) => f.foo; // ERROR

Again, the CFE is correct in rejecting the code.

@stereotype441 stereotype441 added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-spec Issues with the analyzer's implementation of the language spec labels Oct 31, 2024
@stereotype441
Copy link
Member Author

I'm going to work on this.

@stereotype441 stereotype441 self-assigned this Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-spec Issues with the analyzer's implementation of the language spec area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Projects
None yet
Development

No branches or pull requests

1 participant