Skip to content

discrepency between CFE and analyzer's operator == override #50628

Open
@srawlins

Description

@srawlins

See this example from @yanok (dartpad):

abstract class A {
  @override
  bool operator ==(dynamic other);
}

class B implements A {}

void test(dynamic x, dynamic y, dynamic z) {
  print(x == y || x == z);
}

void main() {
  var b1 = B(), b2 = B();
  B? b3;
  print(b1 == null);
  print(b1 == b2);
  print(b3 == b2);
  print(b3 == null);
  test(b1, b2, b3);
}

This program runs without error, but analyzer reports an invalid_implementation_override error at line 6 (class B implements A {}):

'Object.==' ('bool Function(Object)') isn't a valid concrete implementation of 'A.==' ('bool Function(dynamic)').

There is either a bug in analyzer or CFE.

cc @scheglov

Metadata

Metadata

Assignees

No one assigned

    Labels

    legacy-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