sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Fletch allows overloading

Open peter-ahe-google opened this issue 10 years ago • 0 comments

For example, a modified version of tests/unsorted/10_test.dart:

import 'package:expect/expect.dart';

class A {
  A() {
  }

  a() {
    return 12;
  }
}

class B extends A {
  b() {
    return 42;
  }

  a(int x) {
  }
}

main() {
  A a = new B();
  A b = new A();
  Expect.equals(12, b.a());
  Expect.equals(42, a.b());
  Expect.equals(12, a.a());
}

This test is supposed to throw an exception when we call a.a() as the method has been overridden in a subclass. The compiler needs to be aware of this situation and insert a stub in B that throws if you try to call a().

peter-ahe-google avatar Oct 16 '15 15:10 peter-ahe-google