Skip to content

CFE and analyzer disagree on getter/setter consistency requirements #36679

Closed
@leafpetersen

Description

@leafpetersen

The CFE accepts this code with no errors:

class A {
  String operator+(int s) => null;
  void set x(String s) {}
  A get x => this;
}
void main() async {
  var a = new A();
  a.x++;
}

The analyzer rejects it with the following error messages:

  error • The return type of getter 'x' is 'A' which isn't assignable to the type 'String' of its setter 'x' at /Users/leafp/tmp/test1.dart:10:9 • mismatched_getter_and_setter_types
  error • The argument type 'int' can't be assigned to the parameter type 'String' at /Users/leafp/tmp/test1.dart:27:3 • argument_type_not_assignable

@eernstg Can you verify which behavior is consistent with the spec and then re-assign to the appropriate area and team?

cc @stereotype441 @kmillikin

Metadata

Metadata

Assignees

Labels

area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions