Skip to content

Dartc allows a method and getter/setter with the same name #973

@DartBot

Description

@DartBot

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


When getter or setter(implicit or explicit) and a method with the same name are divided into different classes(interfaces), dartc does not produce a compile-time error.
Dartc(r2810) executes this code without errors:
Test 1:
class A {
  foo(){throw new A();}
}

class C extends A {
  get foo() { return "foo()"; }
}

main() {
  new C().foo();
}

Test 2:
class A {
  var foo;
}

class C extends A {
  foo() { return "foo()"; }
}

main() {
  new C().foo();
}

Test 3:
class A {
  void set foo(var x){}
}

class C extends A {
  foo(value) {}
}

main() {
  new C().foo(1);
}

Test 4:
interface S {
  void m();
}

interface I extends S {
  int m;
}

class A implements I {}

main() {
  new A();
}

Test 5:
interface S {
  int m;
}

interface J extends S {
  int m();
}

class A implements J {}

main() {
  new A();
}

 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions