mics icon indicating copy to clipboard operation
mics copied to clipboard

super.foo() doesn't work for mixin's mixins

Open wkeese opened this issue 4 years ago • 0 comments

I constructed a class hierarchy like

B extends A
C extends A
Test extends Root, B, C

It ends up that A is essentially dropped, or at least B and C's calls to super.foo() don't make it to A.

The full test case is:

import { mix } from "mics/src/index";

const Root = mix(Base => class extends Base {
	foo () {
		return "Root";
	}
});

// Root mixin A.
const MixinA = mix(Base => class extends Base {
	foo () {
		return super.foo() + " MixinA ";
	}
});

// Mixin B extends root mixin A.
const MixinB = mix(MixinA, Base => class extends Base {
	foo () {
		return super.foo() + " MixinB ";
	}
});

// Mixin C also extends root mixin A.
const MixinC = mix(MixinA, Base => class extends Base {
	foo () {
		return super.foo() + " MixinC ";
	}
});

// Test extends Root, mixing in B and C
const Test = mix(Root, MixinB, MixinC, Base => class extends Base {
	foo () {
		return super.foo() + " Test";
	}
});

const test = new Test.class();
console.log(test.foo());

wkeese avatar Jun 12 '21 06:06 wkeese