WurstScript icon indicating copy to clipboard operation
WurstScript copied to clipboard

Derived classes are required to re-implement base-class interface-implemented functions when implementing an interface that has a function of the same signature

Open jlfarris91 opened this issue 6 years ago • 0 comments

When I have a base class that implements an interface and a derived class that implements an additional interface where both interfaces have a function of the same signature I have to re-implement the function in the derived class, even though the base class has already implemented it. So, I end up having to write a ton of wrapper functions that just call into the base class in all of my derived classes.

Below is a contrived example. This gets particularly annoying with large interfaces and many derived classes.

interface Foo
  function doSomething()

interface Bar
  function doSomething()

class BaseFoo implements Foo
  override function doSomething()
    Log.info("Some base logic")

class FooBar extends BaseFoo implements Bar
  // FooBar is required to implement Bar.doSomething() again even though I'm satisfied with BaseFoo's implementation
  override function doSomething()
    super.doSomething()

It would be ideal to add a step that would check that a base class has already implemented a function of the same signature to avoid having to write wrapper functions everywhere.

jlfarris91 avatar Oct 12 '19 19:10 jlfarris91