Skip to content

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

@stereotype441

Description

@stereotype441

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.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onarea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions