I have the following smart contracts:
pragma solidity ^0.4.11;
contract base {
uint public v;
separate public mySep;
function base() {
mySep = new separate();
}
function f() {
v = 1;
}
function sepCall() {
mySep.doStuff();
}
}
contract derived is base{
function f() {
v = 2;
super.f();
}
}
contract separate {
derived myBase;
function separate() {
// constructor expects to be called by base or derived
myBase = derived(msg.sender);
}
function doStuff() {
myBase.f();
}
}
I only create an instance of derived
which I expect to do the following:
- call base constructor
base()
- base constructor creates instance
mySep
ofseparate
contract
Now I am calling sepCall
of that derived
instance which I expected to do the following:
- it calls the
doStuff
function of theseparate
contract. - the
doStuff
calls the overridden functionf
of thederived
contract (since that's its type)
The last point is not happening, after calling sepCall
of the derived
instance its value v
is 1 and not 2 which it would be if the overridden function of derived
would have been called.
This might not be solidity related but a general JS issue but I'd like to find out how I could make sepCall
invoke the overridden function f
that sets v
to 2.