uhop / dcl6

OOP with mixins, AOP, chaining for ES6
http://www.dcljs.org
4 stars 0 forks source link

Mixins break static inheritance #2

Open wkeese opened 3 years ago

wkeese commented 3 years ago

Hi Eugene. I'm actually starting to experiment with DCL6 now. I did discover one bug (so far), that mixins "break the inheritance" of static methods.

For example, this (vanilla ES6) demonstrates how subclasses inherit static methods from their superclass:

class A {
    static foo () { console.log("hello world"); }
}

class B extends A {
}

B.foo();

And this also works:

const BWithDcl = dcl(A, Base => class extends Base {} );
BWithDcl.foo();

However, when a mixin is involved, it stops working, and the subclass has no foo() static method:

const Mixin = dcl(null, Base => class extends Base {} );
const BWithDclWithMixin = dcl(A, Mixin, Base => class extends Base {} );
BWithDclWithMixin.foo();
uhop commented 3 years ago

Thank you for the bug report and the repro case. When I wrote dcl6 static methods were not formalized yet, so this is one of less tested features. (The other one is built-in classes).