I want to know who is still able to call an original overwritten function in case of inheritance.
Let's assume I have the following setup:
contract A{
address public owner;
function A(){
owner = msg.sender;
}
function doSomething(){
// does something
}
}
contract B is A{
function doSomething(){
require(msg.sender == owner);
// do something like A but restrict this function execution to owner
super.doSomething();
}
}
If I deploy contract B
can some external account that is not the owner still call doSomething
of parent contract A
? Or could some malicious contract execute the following:
contract EvilDoer{
function doSomethingEvil{
A contractB = A(addressOfdeployedB);
contractB.doSomething();
}
}
Or are overwritten functions shielded from external use?
EDIT: Overloading
Maybe it would be interesting and helpful to me and others to elaborate on the following as well: What happens in case of function overloading, i.e. if the signature in the child class is different from its parent (e.g. assume function doSomething(uint256 someNumber){...}
in contract B
)?