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

No static warning if class declares static method and has setter with the same name #23749

Closed
sgrekhov opened this issue Jun 30, 2015 · 3 comments
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. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@sgrekhov
Copy link
Contributor

Dart specification (v3.0, June 2015) reads (10.7 Static methods):

"It is a static warning if a class C declares a static method named n and has a setter named n ="

In fact no warning produced. The code is the following.

class C {
  static set s1(var value) => {};
  static s1() {
    return 1;
  }

  set s2(var value) => {};
  static s2() {
    return 2;
  }
}

main() {
  var x = C.s1();
}

Dart analyzer shows "No issues found" for this code. dartanalyzer version 1.11.0-edge.45833

@bwilkerson bwilkerson added Type-Defect area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Jun 30, 2015
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed Priority-Medium labels Mar 1, 2016
@floitschG
Copy link
Contributor

Relevant tests:
Language/Classes/Static_Methods/same_name_method_and_setter_t01
Language/Classes/Getters/static_getter_t02
Language/Classes/Setters/static_setter_t06

Also see: #12342, #14427, #21201, and #24534

/ccing @peter-ahe-google and @stereotype441 from frontend-team.

@askeksa-google
Copy link

Check apparently still missing in analyzer. It is pending in CFE, tracked by #33237

@srawlins srawlins added the analyzer-spec Issues with the analyzer's implementation of the language spec label Jun 17, 2020
@srawlins
Copy link
Member

Analyzer now reports the correct errors:

Analyzing 23749.dart...
  error • The name 's1' is already defined. • 23749.dart:3:10 • duplicate_definition
  error • Class 'C' can't define static member 's2' and have instance member 'C.s2' with the same name. • 23749.dart:8:10 • conflicting_static_and_instance

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. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants