Skip to content

Missing override errors on name collisions and default values #27476

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

Closed
sgrekhov opened this issue Oct 4, 2016 · 9 comments
Closed

Missing override errors on name collisions and default values #27476

sgrekhov opened this issue Oct 4, 2016 · 9 comments
Labels
language-strong-mode-polish legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Milestone

Comments

@sgrekhov
Copy link
Contributor

sgrekhov commented Oct 4, 2016

Analyzer has stopped report errors (in a strong mode) in many cases. A couple of examples:

class A {
  static var f;
}
abstract class B extends A {
  f();
}
class C extends B {
  f() {}
}
main() {
  new C().f();
}

Output:
analyzer 1.20.0-dev.10.0 strong mode:
No issues found
analyzer 1.20.0-dev.10.0 nostrong mode:
[warning] 'f' collides with a static member in the superclass 'A'
[warning] 'f' collides with a static member in the superclass 'A'
analyzer 1.19.1 strong mode:
[error] 'f' collides with a static member in the superclass 'A'
[error] 'f' collides with a static member in the superclass 'A'

Another example

class A {
  foo([x = 1]) {}
}
class C extends A {
  foo([x = '']);
}
main() {
  new C().foo(1);
}

Output:
analyzer 1.20.0-dev.10.0 strong mode:
No issues found
analyzer 1.20.0-dev.10.0 nostrong mode:
[warning] Parameters cannot override default values, this method overrides 'A.foo' where this positional parameter has a different value
analyzer 1.19.1 strong mode:
[error] Parameters cannot override default values, this method overrides 'A.foo' where this positional parameter has a different value

@mit-mit
Copy link
Member

mit-mit commented Oct 4, 2016

Tagging as potential 1.20 blocker

@mit-mit mit-mit added legacy-area-analyzer Use area-devexp instead. P1 A high priority bug; for example, a single project is unusable or has many test failures labels Oct 4, 2016
@mit-mit mit-mit added this to the 1.20 milestone Oct 4, 2016
@zoechi
Copy link
Contributor

zoechi commented Oct 4, 2016

Isn't the first case correct?
A class doesn't inherit static members. I don't see a conflict.

@floitschG
Copy link
Contributor

/cc @lrhn

@lrhn
Copy link
Member

lrhn commented Oct 4, 2016

You don't inherit static members, but for some, probably very good, reason the specification does prohibit declaring an instance method with the same name as a static method of a superclass.

Section 10.1:

It is a static warning if a class Cdeclares an instance method namednand an accessible static member namedn` is declared in a superclass of C.

Here "accessible" isn't really necessary, If it's not accessible, then it's a private from another library, and then it won't have the same /name/ as any declaration in the current library.

Not a high priority problem to not warn about this particular thing.

@mit-mit
Copy link
Member

mit-mit commented Oct 4, 2016

Removing blocking 1.20 tag and lowering to P2.

@mit-mit mit-mit added P2 A bug or feature request we're likely to work on and removed P1 A high priority bug; for example, a single project is unusable or has many test failures labels Oct 4, 2016
@mit-mit mit-mit removed this from the 1.20 milestone Oct 4, 2016
@bwilkerson bwilkerson added analyzer-strong-mode type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Oct 4, 2016
@jmesserly
Copy link

Yeah I don't think it's a blocker, but great catch though.

@jmesserly
Copy link

this still repros, and neither the CFE nor Analyzer report it.

@jmesserly jmesserly changed the title Multiple issues in Analyzer 1.20.0-dev.10.0 strong mode missing errors for name collision between static and instance members Jun 27, 2018
@leafpetersen leafpetersen changed the title missing errors for name collision between static and instance members Missing override errors on name collisions and default values Jul 31, 2018
@leafpetersen
Copy link
Member

Note that the first example is now permitted by the spec.

@aadilmaan aadilmaan modified the milestones: Future, D25 Release Jun 4, 2019
@srawlins
Copy link
Member

The second example now has a warning reported by the analyzer:

Parameters can't override default values, this method overrides 'A.foo' where this positional parameter has a different value.

I think this was fixed with the Summary2 work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language-strong-mode-polish legacy-area-analyzer Use area-devexp instead. 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