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

[Language] Abstract or static method named the same as enclosing class #3284

Closed
DartBot opened this issue May 29, 2012 · 5 comments

Comments

Projects
None yet
5 participants
@DartBot
Copy link

commented May 29, 2012

This issue was originally filed by rodion...@unipro.ru


Can't find a mention of this being prohibited anywhere in the spec (0.09) although it probably should be.

VM takes issue with this code (even if the constructor/method is not invoked in main):
class C {
  int C() {}
}

but not with this:

class C {
  abstract C();
}

main() {
    new C();
}

of course, there's a NoSuchMethodException if I try to call 'new C().C()', but no compile-time error.

The result of executing this:

class C {
  static C() {return 1;}
}

main() {
    new C();
}

is also confounding:
Error: line 23 pos 10: invalid arguments passed to constructor 'C' for class 'C'

@kasperl

This comment has been minimized.

Copy link
Contributor

commented May 29, 2012

Added Area-Language, Triaged labels.

@gbracha

This comment has been minimized.

Copy link
Contributor

commented May 29, 2012

I expect to see shadowing warnings on these and no more.


Set owner to @gbracha.
Added Accepted label.

@gbracha

This comment has been minimized.

Copy link
Contributor

commented May 29, 2012

As this stands, the shadowing is warning. Our tendency is to make this an error, interpreting these cases as malformed constructors rather than shadowing methods. Details TBD.


Added this to the M1 milestone.
Removed Type-Defect label.
Added Type-Enhancement label.

@gbracha

This comment has been minimized.

Copy link
Contributor

commented Jul 4, 2012

Added to section 7:

It is compile time error if a class C declares a member with the same name as C.


Added Done label.

@gbracha

This comment has been minimized.

Copy link
Contributor

commented Jul 4, 2012

Analyzer issue: 3986
VM issu : 3987
dart2js issue: 3988

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.