Skip to content

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

Closed

Description

@DartBot

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'

Activity

  1. kasperl commented on May 29, 2012

    @kasperl

    Added Area-Language, Triaged labels.

  2. gbracha commented on May 29, 2012

    @gbracha
    Contributor

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


    Set owner to @gbracha.
    Added Accepted label.

  3. gbracha commented on May 29, 2012

    @gbracha
    Contributor

    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.

  4. gbracha commented on Jul 4, 2012

    @gbracha
    Contributor

    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.

  5. gbracha commented on Jul 4, 2012

    @gbracha
    Contributor

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

  6. added this to the M1 milestone on Jul 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).type-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions