sdk icon indicating copy to clipboard operation
sdk copied to clipboard

No error in analyzer in case of inherited members conflict

Open sgrekhov opened this issue 2 years ago • 5 comments

The followinng code produces an error in CFE but no issues in analyzer

class V1 {
  int m() => 42;
}

class V2 {
  String get m => "42";
}

class V implements V1, V2 {
  String get m => "V"; // Error: Can't declare a member that conflicts with an inherited one.
}

main() {
  print(V);
}

Tested on Dart SDK version: 3.1.0-155.0.dev (dev) (Fri May 26 19:56:47 2023 -0700) on "windows_x64"

sgrekhov avatar Jun 06 '23 09:06 sgrekhov

cc @eernstg to confirm which tool is right here

sgrekhov avatar Jun 06 '23 12:06 sgrekhov

The analyzer is wrong.

lrhn avatar Jun 06 '23 14:06 lrhn

@scheglov Just FYI

bwilkerson avatar Jun 06 '23 15:06 bwilkerson

Right, the relationship between V1.m and V.m is not a correct override, and this is a compile-time error. It is enough that one is a getter and the other is a method, there is no way the return/parameter types can be fiddled such that this is not an error.

eernstg avatar Jun 06 '23 15:06 eernstg

Still no error from analyzer.

srawlins avatar Aug 21 '24 14:08 srawlins